結果
| 問題 | No.355 数当てゲーム(2) |
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2018-03-11 14:47:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,162 bytes |
| 記録 | |
| コンパイル時間 | 1,586 ms |
| コンパイル使用メモリ | 176,768 KB |
| 実行使用メモリ | 25,592 KB |
| 平均クエリ数 | 50.42 |
| 最終ジャッジ日時 | 2024-07-16 15:43:05 |
| 合計ジャッジ時間 | 7,128 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 42 WA * 9 RE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))
using ll = long long;
using P = std::tuple<int,int>;
using P4 = std::tuple<int,int,int,int>;
const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
P ask(int x1, int x2, int x3, int x4){
std::cout << x1 << " " << x2 << " " << x3 << " " << x4 << std::endl;
int a, b;
std::cin >> a >> b;
return std::make_tuple(a, b);
}
P4 f(int a){
int xs[4];
iota(xs, xs+4, a);
int s, t;
tie(s, t) = ask(xs[0], xs[1], xs[2], xs[3]);
if(s == 4){
exit(4);
}
int n = s + t;
int res[4];
fill(res, res+4, -2);
while(true){
int s;
tie(s, ignore) = ask(xs[0], xs[1], xs[2], xs[3]);
if(s == 4){
exit(0);
}else if(s == n){
if(res[0] == -2){
copy(xs, xs+4, res);
}else{
for(int i=0;i<4;++i){
res[i] = xs[i] == res[i] ? res[i] : -1;
}
}
}
if(!next_permutation(xs, xs+4)){
break;
}
}
return std::make_tuple(res[0], res[1], res[2], res[3]);
}
int main(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int as[4], bs[4];
tie(as[0], as[1], as[2], as[3]) = f(0);
tie(bs[0], bs[1], bs[2], bs[3]) = f(4);
for(int i=0;i<4;++i){
as[i] = as[i] != -1 ? as[i] : bs[i];
bs[i] = as[i];
}
{
int nxt = 8;
for(int i=0;i<4;++i){
if(bs[i] == -1){
bs[i] = nxt;
++nxt;
}
}
int s;
tie(s, ignore) = ask(bs[0], bs[1], bs[2], bs[3]);
if(s == 4){
return 0;
}
}
{
copy(as, as+4, bs);
int nxt = 9;
for(int i=0;i<4;++i){
if(bs[i] == -1){
bs[i] = nxt;
--nxt;
}
}
ask(bs[0], bs[1], bs[2], bs[3]);
}
}
tottoripaper