제출 #1364205

#제출 시각아이디문제언어결과실행 시간메모리
1364205avahwCircle Passing (EGOI24_circlepassing)C++20
14 / 100
20 ms580 KiB
#include <bits/stdc++.h>
using namespace std;

int shortest(int start, int end, int ppl){
    if(start > end) swap(start, end);
    int total = ppl * 2 - 1;
    int og_end = end;
    // find dists from startpoint
    int l_dist = end - start;
    int r_dist = start + (total - end) + 1;
    // find dists from friendpoint
    int friendpoint = start + ppl;
    if(og_end < friendpoint) swap(og_end, friendpoint);
    int fl = og_end - friendpoint;
    int fr = friendpoint + (total - end) + 1;
    fl++;
    // cout << "l_dist: " << l_dist << "\n";
    // cout << "r_dist: " << r_dist << "\n";
    // cout << "fl: " << fl << "\n";
    // cout << "fr: " << fr << "\n"; 
    return min({l_dist, r_dist, fl, fr});
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int ppl, frens, qs;
    cin >> ppl >> frens >> qs;
    for(int i = 0; i < frens; i++){
        int thing;
        cin >> thing;
    }
    for(int i = 0; i < qs; i++){
        int a, b;
        cin >> a >> b;
        cout << shortest(a, b, ppl) << "\n";
    }
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…