이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// author - alimammadzade
#include <bits/stdc++.h>
using namespace std;
const int N = 4001;
char c[N][N];
int dx[] = { -1, 1, 0, 0 }, dy[] = { 0, 0, -1, 1 }, n, m, cur;
bool vis[N][N];
void dfs(int x, int y, vector<array<int, 2>>& res) {
vis[x][y] = 1;
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx == 0 or nx > n or ny == 0 or ny > n or c[nx][ny] == '.' or vis[nx][ny]) continue;
if (c[nx][ny] != c[x][y]) res.push_back({ nx, ny });
else dfs(nx, ny, res);
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
system("cls"), freopen("in.txt", "r", stdin);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) cin >> c[i][j];
vector<array<int, 2>> temp, temp1;
dfs(1, 1, temp);
while (!temp.empty()) {
cur++;
temp1.clear();
while (!temp.empty()) {
auto [x, y] = temp.back(); temp.pop_back();
dfs(x, y, temp1);
}
temp = temp1;
}
cout << cur;
}
컴파일 시 표준 에러 (stderr) 메시지
tracks.cpp: In function 'int main()':
tracks.cpp:32:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
32 | auto [x, y] = temp.back(); temp.pop_back();
| ^
tracks.cpp:22:11: warning: ignoring return value of 'int system(const char*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | system("cls"), freopen("in.txt", "r", stdin);
| ~~~~~~^~~~~~~
tracks.cpp:22:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | system("cls"), freopen("in.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |