結果
問題 | No.1588 Connection |
ユーザー | merom686 |
提出日時 | 2021-07-09 00:49:05 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 2,153 ms |
コンパイル使用メモリ | 205,060 KB |
実行使用メモリ | 24,096 KB |
平均クエリ数 | 551.25 |
最終ジャッジ日時 | 2023-09-24 11:56:01 |
合計ジャッジ時間 | 5,453 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
23,244 KB |
testcase_01 | AC | 27 ms
23,976 KB |
testcase_02 | AC | 27 ms
23,316 KB |
testcase_03 | AC | 27 ms
23,868 KB |
testcase_04 | AC | 27 ms
23,496 KB |
testcase_05 | AC | 26 ms
23,484 KB |
testcase_06 | AC | 28 ms
23,856 KB |
testcase_07 | AC | 28 ms
23,472 KB |
testcase_08 | AC | 30 ms
23,988 KB |
testcase_09 | AC | 30 ms
23,736 KB |
testcase_10 | AC | 30 ms
23,340 KB |
testcase_11 | AC | 30 ms
23,484 KB |
testcase_12 | AC | 58 ms
23,868 KB |
testcase_13 | AC | 64 ms
23,664 KB |
testcase_14 | AC | 27 ms
23,304 KB |
testcase_15 | AC | 28 ms
23,208 KB |
testcase_16 | AC | 27 ms
23,244 KB |
testcase_17 | AC | 28 ms
23,484 KB |
testcase_18 | AC | 27 ms
23,424 KB |
testcase_19 | AC | 28 ms
23,484 KB |
testcase_20 | AC | 30 ms
23,460 KB |
testcase_21 | AC | 104 ms
23,328 KB |
testcase_22 | AC | 103 ms
23,220 KB |
testcase_23 | AC | 59 ms
23,616 KB |
testcase_24 | AC | 44 ms
23,208 KB |
testcase_25 | AC | 70 ms
23,460 KB |
testcase_26 | AC | 67 ms
24,096 KB |
testcase_27 | AC | 45 ms
23,304 KB |
testcase_28 | AC | 39 ms
23,856 KB |
testcase_29 | AC | 101 ms
23,328 KB |
testcase_30 | AC | 104 ms
23,220 KB |
testcase_31 | AC | 26 ms
23,472 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int a[502][502]; int main() { int n, m; cin >> n >> m; for (int i = 0; i <= n + 1; i++) { for (int j = 0; j <= n + 1; j++) { a[i][j] = -1; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { a[i][j] = 0; } } a[1][1] = 1; a[n][n] = 1; queue<pair<int, int>> q; q.push({ 1, 1 }); while (!q.empty()) { auto p = q.front(); q.pop(); pair<int, int> d[4] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } }; for (int k = 0; k < 4; k++) { auto t = p; t.first += d[k].first; t.second += d[k].second; if (t.first == n && t.second == n) { cout << "Yes" << endl; exit(0); } int x = a[t.first][t.second]; if (x != 0) continue; cout << t.first << ' ' << t.second << endl; string s; cin >> s; a[t.first][t.second] = s[0] == 'B' ? 1 : 2; if (a[t.first][t.second] == 1) { q.push(t); } } } cout << "No" << endl; return 0; }