QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662775#6303. InversionlibantianWA 49ms35304kbC++231.5kb2024-10-21 10:15:072024-10-21 10:15:07

Judging History

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

  • [2024-10-21 10:15:07]
  • 评测
  • 测评结果:WA
  • 用时:49ms
  • 内存:35304kb
  • [2024-10-21 10:15:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()
const int N=2010;
int a[N],pos[N];
int vis[N][N];
int query(int l,int r){
    if(vis[l][r]!=-1)return vis[l][r];
    cout<<"? "<<l<<" "<<r<<endl;
    cin>>vis[l][r];
    return vis[l][r];
}
int ask(int l,int r){
    if(l+1==r)return query(l,r);
    return query(l+1,r-1)^query(l,r-1)^query(l+1,r)^query(l,r);
}
void solve(){
    int n;
    cin>>n;
    memset(vis,-1,sizeof vis);
    pos[1]=1;
    a[1]=1;
    for(int i=1;i<=n;i++)vis[i][i]=0;
    for(int i=2;i<=n;i++){
        if(ask(pos[i-1],i)==0){
            pos[i]=i;
        }else{
            int l=1,r=i-1;
            while(l<r){
                int mid=l+r>>1;
                if(ask(pos[mid],i))r=mid;
                else l=mid+1;

            }
            for(int j=i;j>l;j--)pos[j]=pos[j-1];
            pos[l]=i;

        }
        for(int j=1;j<=i;j++)a[pos[j]]=j;
        int t=0;
        for(int j=i-1;j;j--){
            if(a[j]>a[i])t^=1;
            vis[j][i]=vis[j][i-1]^t;
        }
    }
    cout<<"! ";
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << setiosflags(ios::fixed) << setprecision(15);
    int T;
    T=1;
    //cin>>T;
    while(T--)solve();
    return 0;
}

详细

Test #1:

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

input:

3
0
1
0

output:

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

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 49ms
memory: 35304kb

input:

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

output:

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

result:

wrong output format Unexpected end of file - int32 expected