結果

問題 No.624 Santa Claus and The Last Dungeon
ユーザー FF256grhyFF256grhy
提出日時 2017-12-24 04:45:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,242 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 175,512 KB
実行使用メモリ 24,276 KB
平均クエリ数 467.56
最終ジャッジ日時 2023-09-23 15:24:06
合計ジャッジ時間 7,867 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
23,520 KB
testcase_01 AC 51 ms
24,144 KB
testcase_02 AC 50 ms
23,580 KB
testcase_03 AC 52 ms
23,676 KB
testcase_04 AC 51 ms
23,448 KB
testcase_05 AC 52 ms
23,544 KB
testcase_06 AC 52 ms
23,412 KB
testcase_07 AC 53 ms
23,892 KB
testcase_08 AC 52 ms
23,412 KB
testcase_09 AC 52 ms
24,276 KB
testcase_10 AC 51 ms
23,256 KB
testcase_11 AC 51 ms
23,892 KB
testcase_12 AC 52 ms
23,928 KB
testcase_13 AC 52 ms
23,712 KB
testcase_14 AC 52 ms
23,880 KB
testcase_15 AC 52 ms
24,264 KB
testcase_16 AC 53 ms
23,880 KB
testcase_17 AC 51 ms
23,544 KB
testcase_18 AC 52 ms
23,712 KB
testcase_19 AC 51 ms
24,144 KB
testcase_20 AC 51 ms
23,472 KB
testcase_21 AC 51 ms
24,084 KB
testcase_22 AC 51 ms
23,724 KB
testcase_23 AC 52 ms
24,240 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 100;

int q, a[M];

int ask() {
	inc(i, M) {
		if(i != 0) { cout << " "; }
		if(a[i] != -1) { printf("%02d", a[i]); } else { cout << "??"; }
	}
	cout << endl;
	
	int x, y, z;
	cin >> x >> y >> z;
	//cin >> z;
	return z;
}

int g(int l, int r, int vl, int vr) {
	int b[M];
	inc(i, M) { b[i] = a[i]; }
	int m = (l + r) / 2;
	inc(i, M) {
		a[i] = (inID(i, l, r) ? (i < m ? vl : vr) : -1);
	}
	
	int val = ask();
	inc(i, M) { a[i] = b[i]; }
	
	return val;
}

int h[M];
vector<array<int, 3>> bi;
void f(int l, int r, vector<int> & v) {
	int n = v.size();
	assert(r - l == n);
	
	if(n == 0) { return; }
	if(n == 1) { a[l] = v[0]; return; }
	if(n == 2) { bi.PB({ l, v[0], v[1] }); return; }
	
	int gg;
	if(n % 2 == 1) {
		gg = g(l, r, v[0], -1);
		h[v[0]] = (gg == 1 ? 0 : 1);
	}
	incID(i, n % 2, n) {
		gg = g(l, r, v[i], v[i + 1]);
		if(gg == 2) { h[v[i]] = 0; h[v[i + 1]] = 1; }
		if(gg == 0) { h[v[i]] = 1; h[v[i + 1]] = 0; }
		if(gg == 1) {
			gg = g(l, r, v[i], -1);
			h[v[i]] = h[v[i + 1]] = (gg == 1 ? 0 : 1);
		}
		
		i++;
	}
	
	vector<int> w[2];
	inc(i, n) { w[h[v[i]]].PB(v[i]); }
	
	int m = (l + r) / 2;
	f(l, m, w[0]);
	f(m, r, w[1]); 
}

void setb(int bp, vector<int> v) {
	inc(i, v.size()) {
		a[bi[bp + i][0] + 0] = bi[bp + i][1 + v[i]];
		a[bi[bp + i][0] + 1] = bi[bp + i][2 - v[i]];
	}
}

int  askb(int bp, vector<int> v) {
	int b[M];
	
	setb(bp, v);
	inc(i, M) { b[i] = a[i]; }
	inc(i, M) { a[i] = -1; }
	setb(bp, v);
	
	int val = ask();
	inc(i, M) { a[i] = b[i]; }
	return val / 2;
}

void bb() {
	int n = bi.size();
	
	inc(i, n) { a[bi[i][0]] = a[bi[i][0] + 1] = -1; }
	
	inc(i, n % 4) {
		if(askb(i, { 0 }) == 0) { setb(i, { 1 }); }
	}
	incID(i, n % 4, n) {
		int gg = askb(i, { 0, 0, 0, 0 });
		if(gg == 4) {  }
		if(gg == 0) { setb(i, { 1, 1, 1, 1 }); }
		if(gg == 3) {
			int hh = askb(i, { 1, 1, 0, 0 });
			if(hh == 3) {
				if(askb(i, { 1, 0, 0, 0 }) == 2) { setb(i, { 0, 1, 0, 0 }); }
			}
			if(hh == 1) {
				if(askb(i, { 0, 0, 1, 0 }) == 2) { setb(i, { 0, 0, 0, 1 }); }
			}
		}
		if(gg == 1) {
			int hh = askb(i, { 0, 0, 1, 1 });
			if(hh == 3) {
				if(askb(i, { 0, 1, 1, 1 }) == 2) { setb(i, { 1, 0, 1, 1 }); }
			}
			if(hh == 1) {
				if(askb(i, { 1, 1, 0, 1 }) == 2) { setb(i, { 1, 1, 1, 0 }); }
			}
		}
		if(gg == 2) {
			int hh = askb(i, { 1, 1, 0, 0 });
			if(hh == 4) { }
			if(hh == 0) { setb(i, { 0, 0, 1, 1 }); }
			if(hh == 2) {
				int ii = askb(i, { 0, 1, 0, 1 });
				if(ii == 4) { }
				if(ii == 0) { setb(i, { 1, 0, 1, 0 }); }
				if(ii == 2) {
					if(askb(i, { 0, 1, 1, 0 }) == 0) { setb(i, { 1, 0, 0, 1 }); } 
				}
			}
		}
		
		i += 3;
	}
}

int main() {
	cin >> q;
	
	vector<int> v;
	inc(i, M) { v.PB(i); }
	f(0, M, v);
	bb();
	ask();
	
	return 0;
}
0