QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#288049#6303. InversionJacka1#WA 1ms3380kbC++201.3kb2023-12-21 17:21:262023-12-21 17:21:27

Judging History

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

  • [2023-12-21 17:21:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3380kb
  • [2023-12-21 17:21:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 2005;
int n, ans[N];

void solve(int l, int r) {
    if(l == r) return ;
    int mid = l + r >> 1, x = 0, y = 0, t;
    cout << "? " << l << " " << mid << endl;
    cin >> x; cout << endl;
    cout << "? " << mid + 1 << " " << r << endl;
    cin >> y; cout << endl;
    for(int i = mid; i >= l; i --) {
        cout << "? " << i << " " << r << endl;
        cin >> t; cout << endl;
        ans[i] += (t - y);
        y = t;
    }
    y = 0;
    for(int i = mid - 1; i >= l; i --) {
        cout << "? " << i << " " << mid << endl;
        cin >> t; cout << endl;
        ans[i] -= (t - y);
        y = t;
    }
    for(int i = mid + 1; i <= r; i ++) {
        cout << "? " << l << " " << i << endl;
        cin >> t; cout << endl;
        ans[i] += i - l - (t - x);
        x = t;
    }
    x = 0;
    for(int i = mid + 2; i <= r; i ++) {
        cout << "? " << mid + 1 << " " << i << endl;
        cin >> t; cout << endl;
        ans[i] -= i - (mid + 1) - (t - x);
        x = t;
    }
    solve(l, mid), solve(mid + 1, r);
}

int main() {
    cin >> n;
    cout << endl;
    solve(1, n);
    cout << "! ";
    for(int i = 1; i <= n; i ++) cout << ans[i] + 1 << " ";
    cout << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3380kb

input:

3
0
0
1
0
0
0
0
0
0
0

output:


? 1 2

? 3 3

? 2 3

? 1 3

? 1 2

? 1 3

? 1 1

? 2 2

? 1 2

? 1 2

! 0 3 3 

result:

wrong output format Unexpected end of file - token expected