# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
535475 | 2022-03-10T10:52:54 Z | dozer | Tracks in the Snow (BOI13_tracks) | C++14 | 1449 ms | 1048576 KB |
#include <bits/stdc++.h> using namespace std; #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout); #define fastio() ios_base::sync_with_stdio(0), cin.tie(0); #define pb push_back #define ll long long #define sp " " #define endl "\n" #define modulo 100000007 #define N 18000005 #define st first #define nd second #define int long long #define pii pair<int, int> vector<int> adj[N]; int id[4005][4005], arr[4015][4005], col[N], dist[N]; unordered_map<char, int> value; int32_t main() { fastio(); #ifndef ONLINE_JUDGE fileio(); #endif //cout<<(((4005 * 4005 * 2) + 6 * N) * 4)/ (1<<20)<<endl; int h, w; cin>>h>>w; value['F'] = 1, value['R'] = 2, value['.'] = 3; int ctr = 1; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { char tmp; cin>>tmp; switch(tmp) { case 'F': arr[i][j] = 1; break; case 'R': arr[i][j] = 2; break; case '.': arr[i][j] = 3; break; } //arr[i][j] = value[tmp]; id[i][j] = ctr; col[id[i][j]] = arr[i][j]; ctr++; } } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (arr[i][j] == 3) continue; int color = arr[i][j]; if (i < h && arr[i + 1][j] != 3) { adj[id[i][j]].pb(id[i + 1][j]); adj[id[i + 1][j]].pb(id[i][j]); } if (j < w && arr[i][j + 1] != 3) { adj[id[i][j]].pb(id[i][j + 1]); adj[id[i][j + 1]].pb(id[i][j]); } } } int color = col[1], ans = 0; deque<int> q; memset(dist, modulo, sizeof(dist)); q.push_front(1); dist[1] = 1; int steps = 0; while(!q.empty()) { steps++; int top = q.front(); q.pop_front(); ans = max(ans, dist[top]); for (int k = 0; k < adj[top].size(); k++) { int curr = adj[top][k]; int d = ((col[top] == col[curr]) ? 0 : 1); if (d == 0 && dist[curr] > dist[top]) { dist[curr] = dist[top]; q.push_front(curr); } else if (d == 1 && dist[curr] > dist[top] + 1) { dist[curr] = dist[top] + 1; q.push_back(curr); } } } //cout<<steps<<endl; cout<<ans<<endl; cerr<<"time taken : "<<(float) clock() / CLOCKS_PER_SEC<<" seconds\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1263 ms | 1048576 KB | Execution killed with signal 11 |
2 | Runtime error | 1270 ms | 1048576 KB | Execution killed with signal 11 |
3 | Runtime error | 1286 ms | 1048576 KB | Execution killed with signal 11 |
4 | Runtime error | 1292 ms | 1048576 KB | Execution killed with signal 11 |
5 | Runtime error | 1295 ms | 1048576 KB | Execution killed with signal 11 |
6 | Runtime error | 1299 ms | 1048576 KB | Execution killed with signal 11 |
7 | Runtime error | 1449 ms | 1048576 KB | Execution killed with signal 11 |
8 | Runtime error | 1284 ms | 1048576 KB | Execution killed with signal 11 |
9 | Runtime error | 1292 ms | 1048576 KB | Execution killed with signal 11 |
10 | Runtime error | 1298 ms | 1048576 KB | Execution killed with signal 11 |
11 | Runtime error | 1274 ms | 1048576 KB | Execution killed with signal 11 |
12 | Runtime error | 1280 ms | 1048576 KB | Execution killed with signal 11 |
13 | Runtime error | 1260 ms | 1048576 KB | Execution killed with signal 11 |
14 | Runtime error | 1267 ms | 1048576 KB | Execution killed with signal 11 |
15 | Runtime error | 1275 ms | 1048576 KB | Execution killed with signal 11 |
16 | Runtime error | 1264 ms | 1048576 KB | Execution killed with signal 11 |
17 | Runtime error | 1267 ms | 1048576 KB | Execution killed with signal 11 |
18 | Runtime error | 1299 ms | 1048576 KB | Execution killed with signal 11 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1290 ms | 1048576 KB | Execution killed with signal 11 |
2 | Runtime error | 1305 ms | 1048576 KB | Execution killed with signal 11 |
3 | Runtime error | 1287 ms | 1048576 KB | Execution killed with signal 11 |
4 | Runtime error | 1281 ms | 1048576 KB | Execution killed with signal 11 |
5 | Runtime error | 1282 ms | 1048576 KB | Execution killed with signal 11 |
6 | Runtime error | 1280 ms | 1048576 KB | Execution killed with signal 11 |
7 | Runtime error | 1274 ms | 1048576 KB | Execution killed with signal 11 |
8 | Runtime error | 1281 ms | 1048576 KB | Execution killed with signal 11 |
9 | Runtime error | 1284 ms | 1048576 KB | Execution killed with signal 11 |
10 | Runtime error | 1279 ms | 1048576 KB | Execution killed with signal 11 |
11 | Runtime error | 1280 ms | 1048576 KB | Execution killed with signal 11 |
12 | Runtime error | 1279 ms | 1048576 KB | Execution killed with signal 11 |
13 | Runtime error | 1302 ms | 1048576 KB | Execution killed with signal 11 |
14 | Runtime error | 1310 ms | 1048576 KB | Execution killed with signal 11 |
15 | Runtime error | 1282 ms | 1048576 KB | Execution killed with signal 11 |
16 | Runtime error | 1305 ms | 1048576 KB | Execution killed with signal 11 |
17 | Runtime error | 1284 ms | 1048576 KB | Execution killed with signal 11 |
18 | Runtime error | 1294 ms | 1048576 KB | Execution killed with signal 11 |
19 | Runtime error | 1291 ms | 1048576 KB | Execution killed with signal 11 |
20 | Runtime error | 1277 ms | 1048576 KB | Execution killed with signal 11 |
21 | Runtime error | 1264 ms | 1048576 KB | Execution killed with signal 11 |
22 | Runtime error | 1271 ms | 1048576 KB | Execution killed with signal 11 |
23 | Runtime error | 1283 ms | 1048576 KB | Execution killed with signal 11 |
24 | Runtime error | 1273 ms | 1048576 KB | Execution killed with signal 11 |
25 | Runtime error | 1280 ms | 1048576 KB | Execution killed with signal 11 |
26 | Runtime error | 1282 ms | 1048576 KB | Execution killed with signal 11 |
27 | Runtime error | 1277 ms | 1048576 KB | Execution killed with signal 11 |
28 | Runtime error | 1308 ms | 1048576 KB | Execution killed with signal 11 |
29 | Runtime error | 1281 ms | 1048576 KB | Execution killed with signal 11 |
30 | Runtime error | 1281 ms | 1048576 KB | Execution killed with signal 11 |
31 | Runtime error | 1267 ms | 1048576 KB | Execution killed with signal 11 |
32 | Runtime error | 1259 ms | 1048576 KB | Execution killed with signal 11 |