QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#472617#6982. Triangulationcoolboy19521AC ✓0ms4080kbC++141.3kb2024-07-11 17:33:332024-07-11 17:33:35

Judging History

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

  • [2024-07-11 17:33:35]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:4080kb
  • [2024-07-11 17:33:33]
  • 提交

answer

#include "triangulation.h"
#include <bits/stdc++.h>

using namespace std;

int solve (int n) {
    auto dist = [&] (int x, int y) {
        if (x == 0 && y == n - 1)
            return n + 1;
        if (abs(x - y) == 1)
            return n + 1;
        if (x == 0) {
            return max(y, n - y);
        }
        if (x > y) {
            swap(x, y);
        }
        return max(x, n - y);
    };
    auto code = [&] (int x, int y) {
        return x * n + y;
    };

    if (query(1, n - 1)) {
        return code(1, n - 1);
    }

    int xAnswer = -1, yAnswer = -1;

    auto verif = [&] (int x, int y) {
        if (xAnswer == -1) {
            xAnswer = x;
            yAnswer = y;
        }
        if (dist(x, y) < dist(xAnswer, yAnswer)) {
            xAnswer = x, yAnswer = y;
        }
    };

    int maxi = 0, mini = n + 1;

    vector<int>v;

    for (int i = 2; i < n - 1; i++) {
        if (query(0, i)) {
            verif(0, i);
            maxi = max(maxi, i);
            mini = min(mini, i);
            v.push_back({i});
        }
    }
    for (int i = 1; i < (int) v.size(); i++) {
        verif(v[i - 1], v[i]);
    }
    verif(1, mini);
    verif(maxi, n - 1);
    return code(xAnswer, yAnswer);
//cout << ans << " - " << n * (n - 3) / 2 << '\n';
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

9
001101110
000000000
100000000
100001000
000000000
100100000
100000000
100000000
000000000
4
0

output:

OK!
7

result:

points 1.0 Correct. q = 7

Test #2:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

7
0001110
0001000
0000000
1100000
1000000
1000000
0000000
4
0

output:

OK!
5

result:

points 1.0 Correct. q = 5

Test #3:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

8
00101110
00000000
10001000
00000000
10100000
10000000
10000000
00000000
4
0

output:

OK!
6

result:

points 1.0 Correct. q = 6

Test #4:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

9
001111110
000000000
100000000
100000000
100000000
100000000
100000000
100000000
000000000
5
1

output:

OK!
7

result:

points 1.0 Correct. q = 7

Test #5:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

9
000000110
000000100
000000100
000000100
000000100
000000000
111110000
100000000
000000000
3
2

output:

OK!
7

result:

points 1.0 Correct. q = 7

Test #6:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

8
00100110
00000000
10000100
00000100
00000000
10110000
10000000
00000000
3
2

output:

OK!
6

result:

points 1.0 Correct. q = 6

Test #7:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

98
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
00000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
...

output:

OK!
1

result:

points 1.0 Correct. q = 1

Test #8:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

98
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000
00011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
...

output:

OK!
96

result:

points 1.0 Correct. q = 96

Test #9:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

98
00111100000000000000000000000000000000000010000111100000001000000000000011111110001000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
...

output:

OK!
96

result:

points 1.0 Correct. q = 96

Test #10:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

96
001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #11:

score: 0
Accepted
time: 0ms
memory: 4020kb

input:

97
0011110000000000000000111000111111000000000000000000001000000000000000000000000000000000011000110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #12:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

100
0011000000001000000000000000000000000000000000000001111111110000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
98

result:

points 1.0 Correct. q = 98

Test #13:

score: 0
Accepted
time: 0ms
memory: 4032kb

input:

97
0010001000000000000000000000000000000000110000010011111110000000000000000000000001111100111111110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #14:

score: 0
Accepted
time: 0ms
memory: 4072kb

input:

97
0011100000000000000000000000000000000000010000001111000111100001100011111111100111111111111110110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #15:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

97
0010001101111111100011111111101101111111000000000000000011111001111111111111110011111111000000110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #16:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

96
001011111111111110010000000000001111111000000000000000000000000000000000000001011000101000000110
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #17:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

96
001011111010000000000000000000000000000000000000000000000101100100111111110001000100000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #18:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

96
001000000000110101111000011111111100000000000000000000000000111110111111011111100110011101100000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #19:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

98
00000000000010001011100000000000000000000000000000000000000001101111001111111111110011011011101110
00010000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
...

output:

OK!
96

result:

points 1.0 Correct. q = 96

Test #20:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

99
000000110001100000000000000000000000000000000000000000000000000000000000000000000111111111011111110
000100100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
97

result:

points 1.0 Correct. q = 97

Test #21:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

99
000001010000000000000000000000000000000000000000000000000000000000000000000000000000011111111111110
000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
97

result:

points 1.0 Correct. q = 97

Test #22:

score: 0
Accepted
time: 0ms
memory: 4080kb

input:

96
001111110000000000000000000000000100001011111111101100001010011111111111100000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #23:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

100
0000001101111111111000001000001111111111111111001111010100000000000000000111111111100110000111111000
0001101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
98

result:

points 1.0 Correct. q = 98

Test #24:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

96
000100111110011100000000000000000000000000000000000000000000000000000000000011000000111101111110
000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
110001...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #25:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

99
000000000000000000000000000010101011111111111011111111111100000000000000000000000001111100000001010
000000000010000000000000000110000000000000000000000000000000000000000000000000000000000000000000000
0000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
97

result:

points 1.0 Correct. q = 97

Test #26:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

98
00000010000000000000011110101111111000000000000000000000000000000000000000000000111100111110101010
00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
...

output:

OK!
96

result:

points 1.0 Correct. q = 96

Test #27:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

96
001101111111111010000000000001110000000000000000000100110000011111000011111110001001000011101110
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100001...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #28:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

96
000001011111111100110000000000001111110011111010111011100000011111100111111001111111100000001000
000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000001...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #29:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

97
0000011111111100101101011100000000000111111011111111011111111100000001111111111111100000001100000
0000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #30:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

100
0010111000000110001100011111110000000000000111111111000011110000000111111101111111100001000011000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
98

result:

points 1.0 Correct. q = 98

Test #31:

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

input:

99
000001111111111010010101011100000000000000000000001111101111111100000000000000000000000010001100110
000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
97

result:

points 1.0 Correct. q = 97

Test #32:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

97
0011000000000000000000000111111000110001111111100111111110111111111111110111111110111111111111110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #33:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

100
0010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
98

result:

points 1.0 Correct. q = 98

Test #34:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

96
000100000110000000000000000001111110001110111000000000000000000110001000100111000000000000011110
000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
110000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #35:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

99
000000111100000011110111111111111111111111111111001000111111110111111000000101101100001111000001110
000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
97

result:

points 1.0 Correct. q = 97

Test #36:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

96
001100000000001111100000000000000000000000000000000000000000000000000000000000000111111111100010
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #37:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

100
0010000001111111000011111100000000000000000111111100001000000000000000000011101111111111111111111110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
98

result:

points 1.0 Correct. q = 98

Test #38:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

96
000000001111101000000000000000001111111000000000000000000000000000000000000000000000110000000010
000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000...

output:

OK!
94

result:

points 1.0 Correct. q = 94

Test #39:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

97
0011000000000001100000000000000000000000000000000000000000000000000000000000000111111011011101110
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100...

output:

OK!
95

result:

points 1.0 Correct. q = 95

Test #40:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

99
001001111111111110010111110001110000000100000111111000000000011001011111111110010011001111111110010
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

OK!
97

result:

points 1.0 Correct. q = 97