結果
| 問題 | No.3598 Queen vs. King |
| コンテスト | |
| ユーザー |
tau1235
|
| 提出日時 | 2026-07-24 23:53:48 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 2,000 ms |
| + 1µs | |
| コード長 | 804 bytes |
| 記録 | |
| コンパイル時間 | 1,989 ms |
| コンパイル使用メモリ | 332,236 KB |
| 実行使用メモリ | 5,888 KB |
| 平均クエリ数 | 2071.58 |
| 最終ジャッジ日時 | 2026-07-24 23:53:52 |
| 合計ジャッジ時間 | 3,663 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
void solve(){
auto f=[&](int i1,int j1,int i2,int j2){
int di=abs(i1-i2),dj=abs(j1-j2);
if (di==0&&dj==0) return true;
if (di==0||dj==0||di==dj) return true;
return false;
};
int h,w;
cin>>h>>w;
int px=1,py=1;
int t=0;
auto out=[&](int i,int j){
cout<<i<<" "<<j<<endl;
px=i;py=j;
};
while (true){
int x,y;
cin>>x>>y;
if (x==0) return;
if (t==0){
if (x-1>1) out(x-1,1);
else out(1,y-1);
}
else{
if (x==h&&f(x-1,y,px,py)) out(x-1,y);
else if (y==w&&f(x,y-1,px,py)) out(x,y-1);
else if (x-px>1){
if (x==h) out(x-1,py);
else out(x,py);
}
else if (y-py>1){
if (y==w) out(px,y-1);
else out(px,y);
}
else assert(0);
}
t++;
}
}
int main(){
int t=1;
cin>>t;
while (t--) solve();
}
tau1235