結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-08 22:58:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 1,155 bytes |
| コンパイル時間 | 1,019 ms |
| コンパイル使用メモリ | 98,640 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 551.25 |
| 最終ジャッジ日時 | 2024-07-17 12:20:33 |
| 合計ジャッジ時間 | 4,692 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int b[550][550] = { 0 };
int b1[4] = { 0,0,1,-1 };
int b2[4] = { 1,-1,0,0 };
int main() {
long long n, m;
cin >> n >> m;
queue<pair<int, int>> que;
que.push(make_pair(1, 1));
b[1][1] = 1;
while (!que.empty()) {
int x = que.front().first, y = que.front().second;
que.pop();
for (int j = 0; j < 4; j++) {
if (x + b1[j] == n && y + b2[j] == n) {
cout << "Yes" << endl;
return 0;
}
if (x + b1[j] <= 0 || x + b1[j] > n || y + b2[j] <= 0 || y + b2[j] > n)continue;
if (b[x + b1[j]][y + b2[j]] == 0) {
cout << x + b1[j] << " " << y + b2[j] << endl;
string s;
cin >> s;
if (s == "-1") {
return 0;
}
else if (s == "Black") {
b[x + b1[j]][y + b2[j]] = 1;
que.push(make_pair(x + b1[j], y + b2[j]));
}
else {
b[x + b1[j]][y + b2[j]] = -1;
}
}
}
}
cout << "No" << endl;
return 0;
}