結果

問題 No.624 Santa Claus and The Last Dungeon
ユーザー FF256grhyFF256grhy
提出日時 2017-12-24 05:21:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,799 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 178,760 KB
実行使用メモリ 25,592 KB
平均クエリ数 454.28
最終ジャッジ日時 2024-07-16 15:09:57
合計ジャッジ時間 7,286 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
25,208 KB
testcase_01 AC 45 ms
25,208 KB
testcase_02 AC 45 ms
24,952 KB
testcase_03 AC 47 ms
24,824 KB
testcase_04 AC 45 ms
24,952 KB
testcase_05 AC 45 ms
25,208 KB
testcase_06 AC 49 ms
24,796 KB
testcase_07 AC 42 ms
24,952 KB
testcase_08 AC 45 ms
24,824 KB
testcase_09 AC 45 ms
24,568 KB
testcase_10 AC 45 ms
25,208 KB
testcase_11 AC 46 ms
24,568 KB
testcase_12 AC 45 ms
25,208 KB
testcase_13 AC 44 ms
25,208 KB
testcase_14 AC 47 ms
25,192 KB
testcase_15 AC 43 ms
25,196 KB
testcase_16 AC 43 ms
24,952 KB
testcase_17 AC 45 ms
25,464 KB
testcase_18 AC 47 ms
25,208 KB
testcase_19 AC 47 ms
25,208 KB
testcase_20 AC 43 ms
24,568 KB
testcase_21 AC 42 ms
24,568 KB
testcase_22 AC 41 ms
24,568 KB
testcase_23 AC 46 ms
25,196 KB
testcase_24 WA -
testcase_25 AC 45 ms
24,824 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 43 ms
24,824 KB
testcase_29 WA -
testcase_30 AC 43 ms
24,568 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 48 ms
24,568 KB
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; }

// ---- ----

bool DBG = false;
const int M = 100;
int key[M] = { 1, 0, 4, 9, 8, 2, 3, 6, 7, 5 };

int q, a[M];

int mid(int l, int r) {
	if(l == 0 && r == M) { return (! DBG ? 64 : 8); }
	return (l + r) / 2;
}

int fg = 0, hi = 0;
void ff(int l, int r) {
	if(r - l == 1) { hi++; return; }
	if(r - l == 2) { fg++; return; }
	int m = mid(l, r);
	ff(l, m);
	ff(m, r);
}

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;
	if(! DBG) { cin >> x >> y >> z; } else {
		z = 0;
		inc(i, M) { if(a[i] == key[i]) { 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 = mid(l, r);
	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();
	if(DBG) {
		cout << " " << l << " - " << r << ": " << n << endl;
		inc(i, n) { cout << v[i] << " "; } cout << endl;
	}
	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 = mid(l, r);
	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() {
	if(! DBG) { cin >> q; }
	
	vector<int> v;
	inc(i, M) { v.PB(i); }
	f(0, M, v);
	if(DBG) { cout << bi.size() << endl; }
	bb();
	ask();
	
	return 0;
}
0