結果

問題 No.1588 Connection
ユーザー HaaHaa
提出日時 2021-07-09 00:27:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,404 bytes
コンパイル時間 1,709 ms
コンパイル使用メモリ 175,208 KB
実行使用メモリ 24,528 KB
平均クエリ数 551.47
最終ジャッジ日時 2023-09-24 11:54:02
合計ジャッジ時間 4,825 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 27 ms
23,556 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 56 ms
23,568 KB
testcase_24 AC 41 ms
23,568 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 103 ms
24,048 KB
testcase_30 AC 103 ms
23,556 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main(){
    int n, m; cin >> n >> m; m-=2;
    queue<P> q;
    q.push({0,0});
    VVI f(n,VI(n,0));
    f[0][0]=1;
    string s;
    int p=3000;
    while(!q.empty()&&p>0){
        p--;
        int x=q.front().first, y=q.front().second;
        q.pop();
        cout << x+1 << " " << y+1 << endl;
        cin >> s;
        if(s=="Black"){
            REP(k,4){
                int tx=x+dx[k];
                int ty=y+dy[k];
                if(tx<0||tx>=n||ty<0||ty>=n)
                    continue;
                if(f[tx][ty])
                    continue;
                f[tx][ty]=1;
                q.push({tx,ty});
            }
            m--;
        }
        else if(s=="-1")
            assert(0);
        if(x==n-1&&y==n-1){
            cout << "Yes" << endl;
            return 0;
        }
        else if(m==0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}
0