QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#678921#6303. InversionFluoresceWA 73ms7724kbC++201.7kb2024-10-26 16:25:472024-10-26 16:25:52

Judging History

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

  • [2024-10-26 16:25:52]
  • 评测
  • 测评结果:WA
  • 用时:73ms
  • 内存:7724kb
  • [2024-10-26 16:25:47]
  • 提交

answer

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define ump unordered_map
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 5e5 + 10, M = 1e4 + 10, mod = 1e9+7;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
	if (f)cout << "YES\n";
	else cout << "NO\n";
}
ll n, m, k;
int a[N],re[N],ans[N];
bool st[N];

bool check(int m,int i){
	int a,b,c,d;
	cout<<"? "<<m<<' '<<i<<endl;
	cin>>a;
	if(m==i-1){
		return a;
	}
	cout<<"? "<<m+1<<' '<<i<<endl;
	cin>>b;
	c=re[m];
	d=re[m+1];
	a=a-b-c+d;
	a=(a%2+2)%2;
	return a;
}

void ini() {
	
}
void solve() {
	cin>>n;
	int x,y,l,r,m;
	for(int i=1;i<=n;++i){
		l=0,r=i;
		while(l<r-1){
			m=l+r>>1;
			if(check(m,i))r=m;
			else l=m;		
		}
		for(int j=i;j>r;--j){
			a[j]=a[j-1];
			st[a[j]]=1;
		}
		a[r]=i;
		x=0;
		for(int j=i;j>=1;--j){
			if(st[j])++x;
			re[j]+=x;
		}
		for(int j=1;j<=i;++j)st[j]=0;
	}
	for(int i=1;i<=n;++i){
		ans[a[i]]=i;
	}
	cout<<"! ";
	for(int i=1;i<=n;++i)cout<<ans[i]<<' ';
	cout<<endl;
}

int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
//#ifndef ONLINE_JUDGE
//	streambuf *cinbp=cin.rdbuf(),*coutbp=cout.rdbuf();
//	ifstream fin("in.txt");
//	ofstream fout("out.txt");	
//	cin.rdbuf(fin.rdbuf());
//	cout.rdbuf(fout.rdbuf());
//#endif
	//cin >> _;
	__ = _;
	ini();
	while (_--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
0
1

output:

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

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 73ms
memory: 7724kb

input:

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

output:

? 1 2
? 1 3
? 2 3
? 2 3
? 2 4
? 3 4
? 3 4
? 2 5
? 3 5
? 1 5
? 2 5
? 3 6
? 4 6
? 1 6
? 2 6
? 3 7
? 4 7
? 1 7
? 2 7
? 4 8
? 5 8
? 2 8
? 3 8
? 3 8
? 4 8
? 4 9
? 5 9
? 2 9
? 3 9
? 3 9
? 4 9
? 5 10
? 6 10
? 7 10
? 8 10
? 8 10
? 9 10
? 5 11
? 6 11
? 8 11
? 9 11
? 9 11
? 10 11
? 10 11
? 6 12
? 7 12
? 3 12
...

result:

wrong answer Wa.