結果

問題 No.3598 Queen vs. King
コンテスト
ユーザー yaaya
提出日時 2026-07-24 22:05:53
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 122 ms / 2,000 ms
+ 1µs
コード長 2,391 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,061 ms
コンパイル使用メモリ 333,920 KB
実行使用メモリ 6,016 KB
平均クエリ数 1917.67
最終ジャッジ日時 2026-07-24 22:05:57
合計ジャッジ時間 3,614 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define ll long long
#define ull unsigned ll
#define ld long double
#define bl __int128_t
#define fi first
#define se second
#define vel vector<ll>
#define vvel vector<vel>
#define pll pair<ll,ll>
#define vepll vector<pll>
#define vvepll vector<vepll>
#define ves vector<string>
#define vem vector<mint>
#define vvem vector<vem>
#define pmm pair<mint,mint>
#define vepmm vector<pmm>
#define cleout(i) cout<<fixed<<setprecision(i)
template<class T>using PQ=priority_queue<T,vector<T>,greater<T>>;
//               上  右 下 左
vector<int> di={-1, 0, 1, 0};
vector<int> dj={ 0, 1, 0,-1};

vector<int> dx={ 0, 1, 0,-1};
vector<int> dy={ 1, 0,-1, 0};


vector<int> ddx={ 1, 1, 1, 0, -1, -1, -1, 0 };
vector<int> ddy={ 1, 0, -1, -1, -1, 0, 1, 1 };

ll inf=1000000000000000000;//1e18
// LLONG_MAX

mt19937_64 rng((ull)chrono::steady_clock::now().time_since_epoch().count());

//[x^M]1/(1-x)^N=comb(N-1+M,M)

void ask(pll &a,pll &res){
    cout<<a.fi<<" "<<a.se<<endl;
    cin>>res.fi>>res.se;
}


void _solve(){
    ll H,W;
    cin>>H>>W;
    pll now={1,1};
    pll res;
    cin>>res.fi>>res.se;
    if(res.fi==H-1&&res.se==W-1){
        if(res.fi-1!=1){
            now.fi=res.fi-1;
            ask(now,res);
            if(res.fi==0)return ;
            now.se=res.se;
            ask(now,res);
            if(res.fi==0)return ;
            now={res.fi-1,res.se};
            ask(now,res);
            if(res.fi==0)return ;
        }else{
            now.se=res.se-1;
            ask(now,res);
            if(res.fi==0)return ;
            now.fi=res.fi;
            ask(now,res);
            if(res.fi==0)return ;
            now={res.fi,res.se-1};
            ask(now,res);
            if(res.fi==0)return ;
        }
    }
    if(res.fi==H){
        now.fi=H-1;
        ask(now,res);
        if(res.fi==0)return ;
        now.se=res.se;
        ask(now,res);
        if(res.fi==0)return ;
    }
    if(res.se==W){
        now.se=W-1;
        ask(now,res);
        if(res.fi==0)return ;
        now.fi=res.fi;
        ask(now,res);
        if(res.fi==0)return ;
    }
}



int main(){
    cin.tie(nullptr);
 	ios_base::sync_with_stdio(false);
    
    ll _;
    bool multitest=1;
    if(multitest)cin>>_;
    else _=1;
    rep(__,0,_){
        _solve();
    }
}
0