이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 4e3 + 5;
int h, w;
string s[N];
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
bool vs[N][N];
queue<pair<int, int>> q[2];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> h >> w;
for(int i = 0; i < h; ++i) cin >> s[i];
bool cur = (s[0][0] == 'F');
vs[0][0] = 1;
q[cur].emplace(0, 0);
int cnt = 0;
while(q[0].size() || q[1].size()) {
while(q[cur].size()) {
auto [u, v] = q[cur].front(); q[cur].pop();
for(int i = 0; i < 4; ++i) {
int x = u + dx[i];
int y = v + dy[i];
if(x < 0 || x >= h || y < 0 || y >= w) continue;
if(vs[x][y] || s[x][y] == '.') continue;
vs[x][y] = 1;
bool tmp = (s[x][y] == 'F');
q[tmp].emplace(x, y);
}
}
++cnt;
cur ^= 1;
}
cout << cnt;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
tracks.cpp: In function 'int main()':
tracks.cpp:24:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
24 | auto [u, v] = q[cur].front(); q[cur].pop();
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |