답안 #1048399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048399 2024-08-08T07:20:44 Z 정희우(#11038) Circle Passing (EGOI24_circlepassing) C++17
14 / 100
21 ms 4744 KB
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using lint = long long;
using vint = vector<int>;
using pii = pair<int,int>;

const int MAX_M=500010;

int n,m,q;
int pos[MAX_M<<2];

int d(int u,int v)
{
    return min(abs(u-v),n*2-abs(u-v));
}

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> m >> q;
    for(int i=1;i<=m;i++)
    {
        cin >> pos[i];
        pos[i+m]=pos[i]+n;
    }
    pos[0]=pos[m]-n;
    pos[m*2+1]=pos[m+1]+n;
    while(q--)
    {
        int u,v;
        cin >> u >> v;
        int l=lower_bound(pos,pos+m*2+2,u)-pos;
        int r=upper_bound(pos,pos+m*2+2,u)-pos-1;
        int a=min(d(u,v),min(d(u,pos[l])+d(v,(pos[l]+n)%(n*2))+1,d(u,pos[r])+d(v,(pos[r]+n)%(n*2)))+1);
        cout << a << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 4 ms 592 KB Output is correct
10 Correct 3 ms 604 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 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 21 ms 4744 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 4 ms 592 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -