QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96469#6303. InversionLiberty12619WA 214ms35168kbC++201.4kb2023-04-13 21:48:302023-04-13 21:48:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 21:48:33]
  • 评测
  • 测评结果:WA
  • 用时:214ms
  • 内存:35168kb
  • [2023-04-13 21:48:30]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 2e3+10,mod = 998244353,INF=1e9+10;
const double eps = 1e-8;
typedef pair<int,int>PII;
typedef pair<int,PII>PIII;
int pos[N],a[N];
int dp[N][N];
int query(int l,int r)
{
	int &v = dp[l][r];
	if(v!=-1)	return v;
    cout<<"? "<<l<<" "<<r<<endl;
    int x;
    cin>>x;
    return v=x;
}
bool check(int mid,int x)
{
    int cnt=0;
    for(int i=pos[mid]+1;i<x;i++)
        if(a[i]<mid)  cnt++;
    int ans = ((query(pos[mid],x)-query(pos[mid]+1,x)-cnt)%2+2)%2;
    return ans;
}
void solve()
{
    int n;
    cin>>n;
    if(n==1)
    {
        cout<<"! "<<1<<endl;
        return;
    }
    memset(dp,-1,sizeof dp);
    int t = query(1,2);
    if(t)
    {
        a[1]=2,a[2]=1;
        pos[1]=2,pos[2]=1;
    }
    else
    {
        a[1]=1,a[2]=2;
        pos[1]=1,pos[2]=2;
    }
    for(int i=3;i<=n;i++)
    {
        int l=1,r=i-1;
        while(l<r)
        {
            int mid = l+r>>1;
            if(check(mid,i))    r=mid;
            else    l=mid+1;
        }
        for(int j=i-1;j>=l;j--) a[pos[j]]++,pos[j+1]=pos[j];
        pos[l]=i,a[i]=l;
    }
    cout<<"!";
    for(int i=1;i<=n;i++)   cout<<" "<<a[i];
    cout<<endl;
}
signed main()
{
    int T =1 ;
    while(T--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 34860kb

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: 214ms
memory: 35168kb

input:

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

output:

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

result:

wrong answer Wa.