QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238036#6303. InversionREN_REN#WA 63ms3500kbC++141.4kb2023-11-04 15:37:482023-11-04 15:37:49

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 15:37:49]
  • 评测
  • 测评结果:WA
  • 用时:63ms
  • 内存:3500kb
  • [2023-11-04 15:37:48]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e5+10;

void solve(){
	int n;
	cin >> n;
	int l, r;
	vector<int> aa;
	aa.push_back(1);
	vector<int> po(n+1);
	po[1] = 1;
	
	for(int i = 2; i <= n; i ++) {
		int numl = 0, numr = i;
		int por = i;
		int h, h1, h2, h3, h4;
		while(numr - numl > 1) {
			int mid = numl + numr >> 1;
			int pol = po[mid];
			if(pol == por - 1) {
				cout << "? " << pol << ' ' << por << endl;
				cin >> h;
				if(h) {
					numr = mid;
				}
				else  numl = mid;
			}
			else {
				int ans = 0;
				cout << "? " << pol << ' ' << por << endl;
				cin >> h2;
				cout << "? " << pol << ' ' << por - 1 << endl;
				cin >> h4;
				if(por - pol == 2) {
					cout << "? " << pol + 1 << ' ' << por << endl;
					cin >> h1;
					ans ^= h1;
				}
				else {
					cout << "? " << pol + 1 << ' ' << por << endl;
					cin >> h1;
					cout << "? " << pol + 1 << ' ' << por - 1 << endl;
					cin >> h3;
					ans ^= h1 ^ h3;
				}
				if(ans ^ h2 ^ h4) {
					numr = mid;
				}
				else numl = mid;
			}
		}
		for(auto &i : aa) {
			if(i >= numr) {
				i ++;
			}
		}
		aa.push_back(numr);
		for(int i = 0; i < aa.size(); i ++) {
			po[aa[i]] = i + 1;
		}
	}
	cout << "! ";
	for(auto i : aa) {
		cout << i << ' ';
	}
	cout << '\n';
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int t;
	solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3388kb

input:

3
0
0
0
1

output:

? 1 2
? 1 3
? 1 2
? 2 3
! 2 3 1 

result:

ok OK, guesses=4

Test #2:

score: -100
Wrong Answer
time: 63ms
memory: 3500kb

input:

1993
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
0
1
1
0
0
0
1
1
1
0
0
0
0
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
0
1
0
1
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
1
0
0
1
1
1
0
1
0
1
1
1
0
1
1
0
0
1
0
1
1
1
0
1
1
1
1
1
0
0
1
0...

output:

? 1 2
? 1 3
? 1 2
? 2 3
? 2 3
? 2 4
? 2 3
? 3 4
? 3 4
? 2 5
? 2 4
? 3 5
? 3 4
? 1 5
? 1 4
? 2 5
? 2 4
? 2 6
? 2 5
? 3 6
? 3 5
? 5 6
? 1 6
? 1 5
? 2 6
? 2 5
? 1 7
? 1 6
? 2 7
? 2 6
? 5 7
? 5 6
? 6 7
? 1 8
? 1 7
? 2 8
? 2 7
? 3 8
? 3 7
? 4 8
? 4 7
? 2 8
? 2 7
? 3 8
? 3 7
? 1 9
? 1 8
? 2 9
? 2 8
? 8 9
...

result:

wrong output format Unexpected end of file - int32 expected