QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489476#8819. CNOI Knowledge_log_WA 2ms7504kbC++17903b2024-07-24 20:31:572024-07-24 20:31:59

Judging History

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

  • [2024-07-24 20:31:59]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7504kb
  • [2024-07-24 20:31:57]
  • 提交

answer

# include <bits/stdc++.h>
# define maxn 1005
# define rep(i, j, k) for(int i = j; i <= k; ++i)
using namespace std;

int n, a[maxn], tot;
int ans[maxn][maxn];

int query(int l, int r) {
    if(l > r) return 0;
    if(ans[l][r] != -1) return ans[l][r];
    cout << "? " << l << ' ' << r << endl;
    cin >> ans[l][r];
    return ans[l][r];
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(ans, -1, sizeof(ans));
    cin >> n; a[1] = ++tot;
    rep(i, 2, n) {
        if(query(1, i) - query(1, i - 1) == i) {a[i] = ++tot; continue;}
        int l = 1, r = i, pos;
        while(l <= r) {
            int mid = l + r >> 1;
            if(query(mid, i) - query(mid, i - 1) == i - mid + 1) pos = mid - 1, r = mid - 1;
            else l = mid + 1;
        }
        a[i] = a[pos];
    }
    rep(i, 1, n) cout << a[i] << '\n';
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7504kb

input:

12
3
1
6
10
15
21
27
10
6
20
15
15
10
34
14
6
3
9
6
43
52
19
14
5
3
2
1
1
62
19
14
5
13
9
8
72
25
9
19

output:

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

result:

wrong answer Invalid output.