제출 #1169781

#제출 시각아이디문제언어결과실행 시간메모리
1169781hijackedsoulCircle Passing (EGOI24_circlepassing)C++20
0 / 100
31 ms16796 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, q; std::cin >> n >> m >> q; std::vector <int> arr; for(int i=0; i<m; i++){ int x; std::cin >> x; arr.push_back(x); arr.push_back(x+n);//idk if i need to push back this, edit: yes arr.push_back(x+n+n); } for(int i=0; i<q; i++){ int a, b; std::cin >> a >> b; if(a>b) swap(a, b); int ans=min(b-a, 2*n+a-b); //else if theres like smth between both of these that can +n then try it ig auto aft=lower_bound(arr.begin(), arr.end(), b); auto mid=lower_bound(arr.begin(), arr.end(), a);//check if <b ltr /*if(aft!=arr.end() && *aft<= a+2*n){ int opp=*aft+n; if(*aft>=2*n) opp%=2*n; int temp=(*aft-b)+1+abs(a-opp); ans=min(ans, temp); }*/ if(mid!=arr.end() && *mid<=b){ int opp=*mid+n; if(*mid>=2*n) opp%=2*n; int temp=(*mid-a)+1+abs(opp-b); ans=min(ans, temp); } std::cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...