# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1083245 | 2024-09-02T19:16:04 Z | vrcoder045 | Tracks in the Snow (BOI13_tracks) | C++14 | 9 ms | 40240 KB |
#include <bits/stdc++.h> using namespace std; #define int long long int P = 1000000007; int P2 = 998244353; #define F first #define S second #define pb push_back #define mp make_pair int dx[4]{1, 0, 0, -1}, dy[4]{0, 1, -1, 0}; void solve () { int h, w; cin >> h >> w; int arr[h][w]; string s; for (int i=0; i<h; ++i) { cin >> s; for (int j=0; j<w; ++j) { arr[i][j] = (s[j] == 'F') ? 2 : ((s[j] == 'R') ? 1 : 0); } } vector<vector<int>> vis(h, vector<int>(w)); deque<pair<int,int>> dq; dq.pb(mp(0,0)); vis[0][0] = 1; int ans = 0; while (!dq.empty()) { pair<int,int> node = dq.front(); dq.pop_front(); ans = max(ans, vis[node.F][node.S]); for (int i=0; i<4; ++i) { int tx = node.F+dx[i], ty = node.S+dy[i]; if (tx<0 || ty<0 || tx>=h || ty>=w) {continue;} if (vis[tx][ty] > 0) {continue;} if (arr[tx][ty]>0 && arr[tx][ty] == arr[node.F][node.S]) { vis[tx][ty] = vis[node.F][node.S]; dq.push_front(mp(tx, ty)); } else if (arr[tx][ty]>0 && arr[tx][ty] != arr[node.F][node.S]) { vis[tx][ty] = vis[node.F][node.S]+1; dq.push_back(mp(tx, ty)); } } } // for (int i=0; i<h; ++i) {for (int j=0; j<w; ++j) {cout << vis[i][j] << " ";} cout << '\n';} cout << ans << '\n'; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t = 1; // cin >> t; for (int _t=0; _t<t;++_t) { // cout << "Case #" << _t+1 << ": "; solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 40024 KB | Execution killed with signal 11 |
2 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
3 | Runtime error | 6 ms | 40100 KB | Execution killed with signal 11 |
4 | Runtime error | 9 ms | 40176 KB | Execution killed with signal 11 |
5 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
6 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
7 | Runtime error | 7 ms | 40240 KB | Execution killed with signal 11 |
8 | Runtime error | 7 ms | 39996 KB | Execution killed with signal 11 |
9 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
10 | Runtime error | 7 ms | 40024 KB | Execution killed with signal 11 |
11 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
12 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
13 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
14 | Runtime error | 6 ms | 40028 KB | Execution killed with signal 11 |
15 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
16 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
17 | Runtime error | 8 ms | 40200 KB | Execution killed with signal 11 |
18 | Runtime error | 6 ms | 40028 KB | Execution killed with signal 11 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 40024 KB | Execution killed with signal 11 |
2 | Runtime error | 7 ms | 40024 KB | Execution killed with signal 11 |
3 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
4 | Runtime error | 8 ms | 40024 KB | Execution killed with signal 11 |
5 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
6 | Runtime error | 6 ms | 40160 KB | Execution killed with signal 11 |
7 | Runtime error | 7 ms | 40032 KB | Execution killed with signal 11 |
8 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
9 | Runtime error | 7 ms | 40024 KB | Execution killed with signal 11 |
10 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
11 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
12 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
13 | Runtime error | 9 ms | 40028 KB | Execution killed with signal 11 |
14 | Runtime error | 7 ms | 40100 KB | Execution killed with signal 11 |
15 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
16 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
17 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
18 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
19 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
20 | Runtime error | 6 ms | 40028 KB | Execution killed with signal 11 |
21 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
22 | Runtime error | 8 ms | 40100 KB | Execution killed with signal 11 |
23 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
24 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
25 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
26 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
27 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
28 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |
29 | Runtime error | 7 ms | 40024 KB | Execution killed with signal 11 |
30 | Runtime error | 8 ms | 40028 KB | Execution killed with signal 11 |
31 | Runtime error | 7 ms | 40024 KB | Execution killed with signal 11 |
32 | Runtime error | 7 ms | 40028 KB | Execution killed with signal 11 |