-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (55 loc) · 1.28 KB
/
main.cpp
File metadata and controls
70 lines (55 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// main.cpp
// JumpGame
//
// Created by 조윤영 on 2020/07/10.
// Copyright © 2020 조윤영. All rights reserved.
//
//https://www.acmicpc.net/problem/15558
//
#include <iostream>
#include <queue>
#define MAX_SIZE 100001
using namespace std;
int N = 0;
int K = 0;
char map[2][MAX_SIZE];
int answer = 0;
int cnt = 0;
void input() {
cin>> N>> K;
for(int i=0; i<N; i++) cin>>map[0][i];
for(int i=0; i<N; i++) cin>>map[1][i];
}
int solution() {
queue<pair<int,int>> q;
q.push({0,0});
while(!q.empty()) {
int qSize = q.size();
for(int i=0; i<qSize; i++) {
int x = q.front().first;
int y = q.front().second;
q.pop();
if(y <cnt) continue;
if(y>=N) return 1;
if(cnt>=N) return 0;
if(map[x][y] == '0') continue;
//1.전진
q.push({x, y+1});
//2.후진
q.push({x, y-1});
//3.점프 +k
if(x == 0) q.push({1, y+K});
else q.push({0, y+K});
}
cnt++;
}
return 0;
}
int main(int argc, const char * argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
input();
cout<<solution()<<"\n";
return 0;
}