답안 #1058088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058088 2024-08-14T08:23:14 Z kachim2 Circle Passing (EGOI24_circlepassing) C++17
56 / 100
210 ms 33316 KB
#include<bits/stdc++.h>
using namespace std;

 
int main(){
    int n, m, q, pbm;
    cin >> n >> m >> q;
    set<int> v;
    auto pos = [n](int x){
        return ((x)+2*n)%(2*n);
    };
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        int y = pos(x+n);
        v.insert(x);
        v.insert(y);
        pbm = x;

    }

    auto dist = [n, &pos](int x, int y){
        return min(pos(pos(x)-pos(y)), pos(pos(y)-pos(x)));
    };
    
    while(q--){
        int x, y;
        cin >> x >> y;

        int bd = dist(x, y);
        auto it1 = v.lower_bound(x);
        if(it1==v.end()){
            it1=v.begin();
        }
        auto it2 = v.upper_bound(x);
        if(it2==v.begin())
        it2=v.end();
        it2--;
        bd = min(dist(x, *it1)+dist(*it1+n, y)+1, bd);
        bd = min(dist(x, *it2)+dist(*it2+n, y)+1, bd);

        cout << bd << '\n';
    }

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:6:18: warning: variable 'pbm' set but not used [-Wunused-but-set-variable]
    6 |     int n, m, q, pbm;
      |                  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 344 KB Output is correct
2 Correct 21 ms 348 KB Output is correct
3 Correct 22 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 24 ms 504 KB Output is correct
6 Correct 24 ms 568 KB Output is correct
7 Correct 33 ms 592 KB Output is correct
8 Correct 32 ms 592 KB Output is correct
9 Correct 28 ms 596 KB Output is correct
10 Correct 28 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 2 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 3 ms 348 KB Output is correct
42 Correct 4 ms 348 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 2 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 210 ms 33316 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 344 KB Output is correct
2 Correct 21 ms 348 KB Output is correct
3 Correct 22 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 24 ms 504 KB Output is correct
6 Correct 24 ms 568 KB Output is correct
7 Correct 33 ms 592 KB Output is correct
8 Correct 32 ms 592 KB Output is correct
9 Correct 28 ms 596 KB Output is correct
10 Correct 28 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 2 ms 348 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 2 ms 348 KB Output is correct
53 Correct 3 ms 348 KB Output is correct
54 Correct 4 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 2 ms 348 KB Output is correct
59 Correct 2 ms 348 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 29 ms 600 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Incorrect 210 ms 33316 KB Output isn't correct
68 Halted 0 ms 0 KB -