QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#297906#6303. InversionPlentyOfPenalty#WA 46ms6364kbC++201.0kb2024-01-05 13:22:132024-01-05 13:22:14

Judging History

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

  • [2024-01-05 13:22:14]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:6364kb
  • [2024-01-05 13:22:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int,int> pii;
const int MAXN = 2011;
int a[MAXN];
pii b[MAXN],tp[MAXN];
map<pii,int>mp;
int get(int l,int r)
{
	if(l>=r)return 0;
	if(mp.count(pii(l,r)))return mp[pii(l,r)];
	cout<<"? "<<l<<" "<<r<<endl;
	int x;
	cin>>x;
	return mp[pii(l,r)]=x;
}
void printans(int n)
{
	cout<<"!";
	for(int i=1;i<=n;++i)cout<<" "<<a[i];
	cout<<endl;
}
bool less(int i,int j)
{
	int all=get(i,j);
	int t=get(i,j-1)^get(i+1,j)^get(i+1,j-1);
	return all==t;
}
void solve(int l,int r)
{
	if(l==r){a[l]=1,b[l]=pii(1,l);return;}
	int mid=(l+r)>>1;
	solve(l,mid),solve(mid+1,r);
	int i=l,j=mid+1,k=l;
	while(i<=mid&&j<=r)
	{
		if(::less(b[i].second,b[j].second))a[b[i].second]+=j-(mid+1), tp[k++]=b[i++];
		else a[b[j].second]+=i-l,tp[k++]=b[j++];
	}
	while(i<=mid)a[b[i].second]+=j-(mid+1),tp[k++]=b[i++];
	while(j<=r)a[b[j].second]+=i-l,tp[k++]=b[j++];
	for(int i=l;i<=r;++i)b[i]=tp[i];
}
int main()
{
	int n;
	cin>>n;
	solve(1,n);
	printans(n);
	return 0;
}
//4 
//4 1 2 3

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3316kb

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: 46ms
memory: 6364kb

input:

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

output:

? 1 2
? 3 4
? 1 3
? 2 3
? 5 6
? 7 8
? 5 7
? 6 7
? 5 8
? 6 8
? 1 7
? 1 6
? 2 7
? 2 6
? 1 5
? 1 4
? 2 5
? 2 4
? 1 8
? 2 8
? 3 8
? 3 7
? 4 8
? 4 7
? 9 10
? 11 12
? 10 11
? 9 11
? 9 12
? 10 12
? 13 14
? 15 16
? 14 15
? 13 15
? 13 16
? 14 16
? 10 14
? 10 13
? 11 14
? 11 13
? 12 14
? 12 13
? 11 15
? 12 15...

result:

wrong output format Unexpected end of file - int32 expected