QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#666512#8939. Permutationxh_team#WA 129ms3784kbC++201.8kb2024-10-22 18:51:582024-10-22 18:52:04

Judging History

This is the latest submission verdict.

  • [2024-10-22 18:52:04]
  • Judged
  • Verdict: WA
  • Time: 129ms
  • Memory: 3784kb
  • [2024-10-22 18:51:58]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2014;

mt19937 rnd(time(0));

int a[] = {-1, 4, 7, 2, 6, 5, 1, 9};

int ask(int l, int r) {
    cout << '?' << ' ' << l << ' ' << r << endl;
    int x;
    cin >> x;
    return x;


    // int fi = -1, se = -1;
    // for (int i = l; i <= r; i++) {
    //     fi = max(fi, a[i]);
    // }
    // int x = -1;
    // for (int i = l; i <= r; i++) {
    //     if (a[i] != fi && a[i] > se) {
    //         se = a[i];
    //         x = i;
    //     }
    // }
    // return x;
}

int n, p, ans;
void dfs(int l, int r) {
    if (r - l == 1) {
        ans = l + r - p;
        return;
    }
    if (r - l == 2) {
        if (p == l) {
            int q = ask(l + 1, r);
            ans = l + 1 + r - q;
        } else if (p == r) {
            int q = ask(l, l + 1);
            ans = l + l + 1 - q;
        } else {
            int q = ask(l, l + 1);
            if (p == q) {
                ans = l;
            } else {
                ans = r;
            }
        }
        return;
    }

    int len23 = (r - l + 1) * 2 / 3;
    if (p <= l + len23 - 1) {
        int q = ask(l, l + len23 - 1);
        if (p == q) {
            dfs(l, l + len23 - 1);
        } else {
            p = ask(l + len23, r);
            dfs(l + len23, r);
        }
    } else {
        int q = ask(r - len23 + 1, r);
        if (p == q) {
            dfs(r - len23 + 1, r);
        } else {
            p = ask(l, r - len23);
            dfs(l, r - len23);
        }
    }

}

void solve() {
    cin >> n;
    p = ask(1, n);
    dfs(1, n);
    cout << '!' << ' ' << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);

    int tt;
    cin >> tt;
    while (tt--) solve();

    return 0;
}

詳細信息

Test #1:

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

input:

3
5
3
2
5
6
6
3
1
4
3
3

output:

? 1 5
? 1 3
? 4 5
! 4
? 1 6
? 3 6
? 1 2
! 2
? 1 4
? 3 4
! 4

result:

ok Correct (3 test cases)

Test #2:

score: 0
Accepted
time: 64ms
memory: 3708kb

input:

10000
10
2
2
2
1
3
10
10
10
7
5
10
5
1
10
9
8
10
4
4
4
4
10
10
6
3
4
2
10
3
3
3
4
2
10
1
5
9
10
7
10
1
3
8
8
10
2
4
9
9
10
3
3
3
3
10
4
1
7
8
9
10
8
7
1
2
4
10
4
1
9
9
10
7
7
7
8
6
10
5
1
7
8
10
10
8
8
6
9
10
2
2
1
5
10
6
4
10
10
10
1
3
8
8
10
7
9
4
4
10
7
8
4
4
10
3
4
7
8
10
10
4
4
1
6
10
8
7
4
3
2...

output:

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

result:

ok Correct (10000 test cases)

Test #3:

score: 0
Accepted
time: 44ms
memory: 3676kb

input:

10000
3
1
2
11
5
5
5
4
7
2
2
19
3
3
4
12
11
9
7
5
7
1
2
3
3
1
19
6
6
6
7
1
2
2
2
15
11
11
11
11
10
8
14
1
1
1
1
2
3
16
4
4
4
1
5
3
3
2
19
13
17
5
6
2
1
2
2
4
1
2
3
7
2
2
2
3
2
2
17
1
1
1
2
6
6
14
9
1
12
12
11
20
9
9
9
6
13
11
6
4
2
5
18
7
7
7
7
7
6
8
8
8
6
5
8
6
6
6
5
16
10
10
10
10
10
6
1
1
2
3
10
...

output:

? 1 3
? 2 3
! 3
? 1 11
? 1 7
? 4 7
? 4 5
? 6 7
! 6
? 1 2
! 1
? 1 19
? 1 12
? 1 8
? 9 12
? 11 12
? 9 10
! 10
? 1 7
? 4 7
? 1 3
? 2 3
! 3
? 1 3
? 1 2
! 2
? 1 19
? 1 12
? 1 8
? 4 8
? 1 3
? 2 3
! 3
? 1 2
! 1
? 1 15
? 6 15
? 6 11
? 8 11
? 10 11
? 8 9
! 9
? 1 14
? 1 9
? 1 6
? 1 4
? 1 2
? 3 4
! 4
? 1 16
? ...

result:

ok Correct (10000 test cases)

Test #4:

score: 0
Accepted
time: 124ms
memory: 3704kb

input:

10000
47
23
23
31
11
9
2
1
3
14
8
2
14
13
11
25
6
6
4
13
13
13
7
4
2
6
6
9
2
2
2
2
27
27
27
27
27
24
21
20
21
7
7
7
7
7
6
5
43
41
21
7
7
8
4
3
1
22
6
14
20
20
19
21
34
29
29
25
17
17
17
16
42
20
20
20
20
20
20
20
19
47
21
21
21
21
21
21
19
17
41
25
11
30
33
39
39
38
19
17
17
16
9
8
10
21
14
14
14
14...

output:

? 1 47
? 1 31
? 12 31
? 1 11
? 5 11
? 1 4
? 1 2
? 3 4
! 4
? 1 14
? 1 9
? 10 14
? 12 14
? 10 11
! 10
? 1 25
? 1 16
? 1 10
? 11 16
? 11 14
? 13 14
! 14
? 1 7
? 1 4
? 5 7
? 5 6
! 5
? 1 9
? 1 6
? 1 4
? 1 2
! 1
? 1 27
? 10 27
? 16 27
? 20 27
? 23 27
? 20 22
? 20 21
! 22
? 1 21
? 1 14
? 1 9
? 4 9
? 4 7
? ...

result:

ok Correct (10000 test cases)

Test #5:

score: 0
Accepted
time: 78ms
memory: 3784kb

input:

10000
100
47
61
93
96
71
71
71
71
69
9
2
2
2
1
4
53
46
35
6
6
6
6
6
4
33
3
16
31
31
31
30
32
82
60
29
4
8
23
21
28
27
26
88
39
39
39
25
51
48
56
54
57
71
24
29
59
59
59
54
60
61
63
92
52
45
88
88
88
88
85
91
91
24
11
11
9
5
5
6
3
66
51
51
51
51
51
45
40
40
92
43
43
50
20
20
20
20
20
21
19
48
1
1
1
1...

output:

? 1 100
? 1 66
? 67 100
? 79 100
? 67 78
? 67 74
? 67 71
? 69 71
? 69 70
! 70
? 1 9
? 1 6
? 1 4
? 1 2
? 3 4
! 3
? 1 53
? 19 53
? 1 18
? 1 12
? 1 8
? 4 8
? 4 6
? 4 5
! 5
? 1 33
? 1 22
? 23 33
? 27 33
? 30 33
? 30 31
? 32 33
! 33
? 1 82
? 29 82
? 1 28
? 1 18
? 19 28
? 19 24
? 25 28
? 27 28
? 25 26
! 2...

result:

ok Correct (10000 test cases)

Test #6:

score: 0
Accepted
time: 85ms
memory: 3708kb

input:

10000
50
10
10
10
10
14
2
3
5
50
11
11
9
31
32
23
23
50
44
44
40
20
20
21
23
22
50
24
14
45
45
40
49
50
48
50
50
50
50
50
50
50
49
45
50
36
23
17
17
12
8
7
10
50
29
29
20
3
3
3
3
50
30
30
22
1
1
1
2
4
50
25
25
25
15
30
30
30
29
50
18
20
49
47
37
34
39
50
9
9
9
9
5
14
14
13
50
26
26
26
28
17
19
12
13...

output:

? 1 50
? 1 33
? 1 22
? 1 14
? 6 14
? 1 5
? 1 3
? 4 5
! 4
? 1 50
? 1 33
? 1 22
? 23 33
? 27 33
? 23 26
? 23 24
! 24
? 1 50
? 18 50
? 29 50
? 18 28
? 18 24
? 18 21
? 22 24
? 22 23
! 24
? 1 50
? 1 33
? 34 50
? 40 50
? 40 46
? 47 50
? 49 50
? 47 48
! 47
? 1 50
? 18 50
? 29 50
? 37 50
? 42 50
? 45 50
? 4...

result:

ok Correct (10000 test cases)

Test #7:

score: 0
Accepted
time: 129ms
memory: 3736kb

input:

10000
100
76
35
5
5
5
3
11
11
11
100
29
29
29
29
29
29
29
29
27
26
100
64
38
69
69
72
88
86
83
81
100
51
57
98
98
92
79
79
81
83
100
44
44
44
42
13
13
12
9
9
100
64
64
64
64
62
41
41
41
40
39
100
93
93
86
56
56
49
44
45
47
100
37
2
97
81
76
77
68
67
70
100
76
76
58
94
95
80
79
86
85
100
32
32
11
59
...

output:

? 1 100
? 35 100
? 1 34
? 1 22
? 1 14
? 1 9
? 10 14
? 10 12
? 10 11
! 10
? 1 100
? 1 66
? 1 44
? 1 29
? 11 29
? 18 29
? 22 29
? 25 29
? 27 29
? 25 26
! 25
? 1 100
? 1 66
? 67 100
? 67 88
? 67 80
? 81 88
? 84 88
? 81 83
? 81 82
! 82
? 1 100
? 1 66
? 67 100
? 79 100
? 87 100
? 79 86
? 79 83
? 79 81
? ...

result:

ok Correct (10000 test cases)

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3720kb

input:

1000
1000
475
426
728
728
747
867
867
867
858
841
841
842
844
845
1000
278
278
17
446
461
598
637
665
664
647
647
647
646
645
1000
75
128
871
871
842
686
713
732
732
730
735
737
739
1000
239
239
45
577
577
520
458
458
458
451
459
460
466
465
1000
978
978
978
978
978
978
978
997
914
914
914
920
923
9...

output:

? 1 1000
? 1 666
? 667 1000
? 667 888
? 667 814
? 815 888
? 840 888
? 840 871
? 851 871
? 840 850
? 840 846
? 840 843
? 844 846
? 845 846
! 846
? 1 1000
? 1 666
? 1 444
? 445 666
? 445 592
? 593 666
? 593 641
? 642 666
? 651 666
? 642 650
? 642 647
? 644 647
? 646 647
? 644 645
! 644
? 1 1000
? 1 66...

result:

wrong answer Too many queries , n = 1000 , now_q 16 (test case 41)