QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489921#8819. CNOI Knowledge_log_WA 259ms38328kbC++142.3kb2024-07-25 09:00:012024-07-25 09:00:03

Judging History

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

  • [2024-07-25 09:00:03]
  • 评测
  • 测评结果:WA
  • 用时:259ms
  • 内存:38328kb
  • [2024-07-25 09:00:01]
  • 提交

answer

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

int n, tot;
int a[maxn], ans[maxn][maxn];
int d[maxn];
ull has[maxn], pw[maxn];
map<ull, int> mp;

namespace Garder {
    int ans[10][10] = {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 1, 3, 6, 9, 12, 18, 24, 31, 0},
        {0, 0, 1, 3, 5, 7, 12, 17, 23, 0},
        {0, 0, 0, 1, 3, 5, 9, 13, 19, 0},
        {0, 0, 0, 0, 1, 3, 6, 9, 14, 0},
        {0, 0, 0, 0, 0, 1, 3, 6, 10, 0}, 
        {0, 0, 0, 0, 0, 0, 1, 3, 6, 0},
        {0, 0, 0, 0, 0, 0, 0, 1, 3, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    };
}

inline int query(int l, int r) {
    if(ans[l][r]) return ans[l][r];
    cout << "? " << l << ' ' << r << endl;
    // ans[l][r] = Garder::ans[l][r];
    cin >> ans[l][r];
    return ans[l][r];
}

void update(int r) {
    memset(d, 0, sizeof(d));
    rep(i, 1, r) {
        ull hsh = has[r] - has[i - 1] * pw[r - i + 1], len = r - i + 1;
        // cerr << i << ' ' << r << ' ' << hsh << ' ' << mp.count(hsh) << '\n';
        if(!mp.count(hsh)) d[1]++;
        else d[mp[hsh] - len + 2]++;
        d[i + 1]--; mp[hsh] = r;
    }
    rep(i, 1, r) d[i] += d[i - 1];
    // cout << r << " : ";
    // rep(i, 1, n) cout << d[i] << ' '; cout << '\n';
    rep(l, 1, r) ans[l][r] = ans[l][r - 1] + d[l];
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n; a[1] = ++tot; ans[1][1] = 1; has[1] = 1;
    pw[0] = 1; rep(i, 1, n) pw[i] = pw[i - 1] * 19260817;
    rep(i, 2, n) {
        int now = query(1, i);
        if(now - ans[1][i - 1] == i) a[i] = ++tot;
        else {
            int l = 1, r = i, pos, mid;
            while(l <= r) {
                mid = l + r >> 1;
                if(query(mid, i) - ans[mid][i - 1] == i - mid + 1) pos = mid - 1, r = mid - 1;
                else l = mid + 1;
            }
            a[i] = a[pos];
        }
        has[i] = has[i - 1] * 19260817 + a[i]; update(i);
    }
    // rep(i, 1, n) {
    //     rep(j, 1, n) cerr << ans[i][j] << ' ';
    //     cerr << '\n';
    // }
    cout << "! ";
    rep(i, 1, n) cout << a[i] << ' ';
    cout << '\n';
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Accepted. 28 queries used.

Test #2:

score: 0
Accepted
time: 259ms
memory: 38328kb

input:

1000
3
5
2
1
7
3
2
1
11
5
7
16
8
2
1
21
7
2
1
27
11
5
7
34
11
5
3
41
15
5
2
1
48
15
3
2
1
57
19
4
2
1
66
17
4
2
1
75
20
4
2
1
84
15
4
2
1
96
23
9
13
15
108
23
11
5
3
124
31
11
5
3
140
36
11
5
2
1
156
45
15
3
2
1
172
48
15
5
11
7
188
58
16
5
2
1
208
59
16
5
12
8
229
69
21
8
2
1
251
69
20
8
3
5
273
79...

output:

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

result:

ok Accepted. 9789 queries used.

Test #3:

score: -100
Wrong Answer
time: 62ms
memory: 7568kb

input:

1000
2
1
3
2
1
7
5
11
5
8
15
7
11
21
7
16
11
27
11
5
8
33
11
3
2
1
40
14
3
2
1
47
11
31
23
17
54
13
36
27
20
61
7
4
2
1
71
15
51
32
23
81
20
8
2
1
94
28
12
5
8
107
31
12
5
8
120
38
11
3
2
1
133
38
9
26
20
14
148
44
14
5
9
163
44
14
5
11
8
179
54
15
3
2
1
199
56
14
3
2
1
219
65
17
4
2
1
240
66
17
7
1...

output:

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

result:

wrong answer Wrong Answer.