結果

問題 No.355 数当てゲーム(2)
ユーザー かにかに
提出日時 2017-04-01 22:40:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,347 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 171,136 KB
実行使用メモリ 38,368 KB
平均クエリ数 1.56
最終ジャッジ日時 2024-07-17 00:51:35
合計ジャッジ時間 5,854 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 TLE * 1 -- * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define mp(a,b) make_pair(a,b)
using namespace std;typedef long long ll;typedef unsigned long long ull;int dx[] = { 1, -1 , 0 , 0};int dy[] = { 0,  0,  1, -1};

void solve() {
  int a,x,y,first,last;
  vi v;
  cout << 0 << " " << 1 << " " << 2 << " " << 3 << endl;
  cin >> x >> y;
  first = x + y;
  if(x + y != 4){
    REP(i,4,10){
      cout << 0 << " " << 1 << " " << 2 << " " << i << endl;
      cin >> x >> y;
      if(x + y >= first)v.push_back(i);
      if(v.size()+first == 4)break;
    }
  }
  if(v.size() != 4){
    v.push_back(0);
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
  }
  while(true){
    do{
      printf("%d %d %d %d\n",v[0],v[1],v[2],v[3]);
      cin >> x >> y;
      if(x == 4)return;
      if(x + y == 4){
	vi ne;
	ne.push_back(v[0]);
	ne.push_back(v[1]);
	ne.push_back(v[2]);
	ne.push_back(v[3]); 
	do{
	  printf("%d %d %d %d\n",ne[0],ne[1],ne[2],ne[3]);
	  cin >> x >> y;
	  if(x == 4)return;
	}while(next_permutation(ne.begin(),ne.end()));
      }
    }while(next_permutation(v.begin(),v.end()));
  }
}

int main() {
	solve();
	return 0;
}
0