結果
問題 | No.340 雪の足跡 |
ユーザー | 🍮かんプリン |
提出日時 | 2020-06-01 01:42:10 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,580 bytes |
コンパイル時間 | 3,920 ms |
コンパイル使用メモリ | 158,832 KB |
実行使用メモリ | 15,468 KB |
最終ジャッジ日時 | 2023-08-12 16:32:15 |
合計ジャッジ時間 | 13,244 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 3 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 3 ms
4,380 KB |
testcase_14 | AC | 17 ms
4,376 KB |
testcase_15 | AC | 21 ms
4,384 KB |
testcase_16 | AC | 15 ms
4,380 KB |
testcase_17 | AC | 27 ms
4,444 KB |
testcase_18 | AC | 23 ms
4,416 KB |
testcase_19 | AC | 27 ms
4,472 KB |
testcase_20 | AC | 275 ms
15,200 KB |
testcase_21 | AC | 173 ms
4,380 KB |
testcase_22 | AC | 13 ms
15,260 KB |
testcase_23 | WA | - |
testcase_24 | AC | 271 ms
15,180 KB |
testcase_25 | AC | 299 ms
15,252 KB |
testcase_26 | AC | 46 ms
4,376 KB |
testcase_27 | AC | 9 ms
4,384 KB |
testcase_28 | AC | 40 ms
4,376 KB |
testcase_29 | AC | 341 ms
10,400 KB |
testcase_30 | AC | 229 ms
8,620 KB |
testcase_31 | AC | 351 ms
14,156 KB |
testcase_32 | AC | 415 ms
15,188 KB |
testcase_33 | AC | 321 ms
15,188 KB |
testcase_34 | AC | 414 ms
15,260 KB |
testcase_35 | AC | 310 ms
15,260 KB |
testcase_36 | AC | 306 ms
15,468 KB |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.01 01:42:06 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int w, h; vector< vector< int > > g1, g2; void f(int x, int y) { if (x > y) swap(x, y); if (x % w == y % w) { g1[x / w][x % w]++; g1[y / w + 1][y % w]--; } else { g2[x / w][x % w]++; g2[y / w][y % w + 1]--; } } int main() { int n; cin >> w >> h >> n; g1.resize(h + 1, vector< int >(w + 1,0));//縦 g2.resize(h + 1, vector< int >(w + 1,0));//横 for (int i = 0; i < n; i++) { int m; cin >> m; int pre = -1; for (int i = 0; i < m + 1; i++) { int b; cin >> b; if (pre != -1) { f(pre,b); } pre = b; } } for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { g1[j+1][i] += g1[j][i]; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { g2[i][j+1] += g2[i][j]; } } vector<vector<int>> dist(h,vector<int>(w,-1)); dist[0][0] = 0; queue<pair<int,int>> que; que.push({0,0}); while(!que.empty()) { auto p = que.front(); que.pop(); int nx = p.first; int ny = p.second; { int x = nx + 1; int y = ny; if (x >= 0 && x < h && y >= 0 && y < w && g1[nx][ny] > 0 && g1[x][y] > 0 && dist[x][y] == -1) { dist[x][y] = dist[nx][ny] + 1; que.push({x,y}); } } { int x = nx - 1; int y = ny; if (x >= 0 && x < h && y >= 0 && y < w && g1[nx][ny] > 0 && g1[x][y] > 0 && dist[x][y] == -1) { dist[x][y] = dist[nx][ny] + 1; que.push({x,y}); } } { int x = nx; int y = ny + 1; if (x >= 0 && x < h && y >= 0 && y < w && g2[nx][ny] > 0 && g2[x][y] > 0 && dist[x][y] == -1) { dist[x][y] = dist[nx][ny] + 1; que.push({x,y}); } } { int x = nx; int y = ny - 1; if (x >= 0 && x < h && y >= 0 && y < w && g2[nx][ny] > 0 && g2[x][y] > 0 && dist[x][y] == -1) { dist[x][y] = dist[nx][ny] + 1; que.push({x,y}); } } } if (dist[h-1][w-1] == -1) { puts("Odekakedekinai.."); } else { cout << dist[h-1][w-1] << endl; } return 0; }