답안 #1058085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058085 2024-08-14T08:19:38 Z kachim2 Circle Passing (EGOI24_circlepassing) C++17
14 / 100
211 ms 36796 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);
        auto it2 = v.upper_bound(x);
        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 23 ms 344 KB Output is correct
2 Correct 21 ms 464 KB Output is correct
3 Correct 22 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 24 ms 344 KB Output is correct
6 Correct 24 ms 600 KB Output is correct
7 Correct 30 ms 860 KB Output is correct
8 Correct 27 ms 856 KB Output is correct
9 Correct 27 ms 960 KB Output is correct
10 Correct 27 ms 856 KB Output is correct
11 Correct 0 ms 436 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 211 ms 36796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 344 KB Output is correct
2 Correct 21 ms 464 KB Output is correct
3 Correct 22 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 24 ms 344 KB Output is correct
6 Correct 24 ms 600 KB Output is correct
7 Correct 30 ms 860 KB Output is correct
8 Correct 27 ms 856 KB Output is correct
9 Correct 27 ms 960 KB Output is correct
10 Correct 27 ms 856 KB Output is correct
11 Correct 0 ms 436 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -