結果
| 問題 | No.1588 Connection |
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2021-07-08 22:55:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 136 ms / 2,000 ms |
| コード長 | 1,426 bytes |
| コンパイル時間 | 2,664 ms |
| コンパイル使用メモリ | 205,488 KB |
| 最終ジャッジ日時 | 2025-01-22 19:04:39 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using point = pair<int, int>;
enum
{
unknown = 0,
black = 1,
white = 2,
};
vector dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int main()
{
int n, m;
cin >> n >> m;
vector color(n, vector<int>(n, unknown));
color.at(0).at(0) = black;
queue<point> q;
q.emplace(0, 0);
while (not q.empty())
{
auto [x, y] = q.front();
q.pop();
for (int i = 0; i < 4; i++)
{
int x_next = x + dx.at(i), y_next = y + dy.at(i);
if (x_next < 0 or n <= x_next or y_next < 0 or n <= y_next)
{
continue;
}
if (color.at(x_next).at(y_next) != unknown)
{
continue;
}
if (x_next == n - 1 and y_next == n - 1)
{
cout << "Yes" << endl;
return 0;
}
cout << x_next + 1 << ' ' << y_next + 1 << endl;
string res;
cin >> res;
if (res == "Black")
{
color.at(x_next).at(y_next) = black;
q.emplace(x_next, y_next);
}
else if (res == "White")
{
color.at(x_next).at(y_next) = white;
}
else
{
return 0;
}
}
}
cout << "No" << endl;
return 0;
}
trineutron