제출 #1297370

#제출 시각아이디문제언어결과실행 시간메모리
1297370Bui_Quoc_CuongCircle Passing (EGOI24_circlepassing)C++20
14 / 100
120 ms38756 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class A, class B> bool maximize(A &a, const B b) { if (a < b) { a = b; return true; } return false; } template <class A, class B> bool minimize(A &a, const B b) { if(a > b) { a = b; return true; } return false; } using pII = pair <int, int>; using vI = vector <int>; using vL = vector <long long>; using pLI = pair <long long, int>; #define BIT(mask, i) ((mask >> (i)) & 1) #define MASK(a) (1LL<<(a)) #define FOR(i, a, b) for(int i = a; i <= (int)b; i++) #define FORD(i, a, b) for(int i = a; i >= (int)b; i--) #define fi first #define se second #define pb push_back #define all(a) a.begin(), a.end() #define sz(a) (int)a.size() const int mod = 1e9 + 7; const int maxn = 2e5 + 5; int n, m, q; map <int, vector <int>> g; int calc(int x, int y) { return min(abs(x - y), 2 * n - abs(x - y)); } void process () { cin >> n >> m >> q; FOR(i, 1, m) { int x; cin >> x; g[x].push_back(n + x); } while(q--) { int st, ed; cin >> st >> ed; map <pair <int, int>, int> dp; #define bg array <int, 3> priority_queue <bg, vector <bg>, greater <bg>> pq; pq.push({dp[{st, 0}] = 0, st, 0}); int ans = 2e9 + 10; while(sz(pq)) { auto [cost, u, t] = pq.top(); pq.pop(); if(cost > dp[make_pair(u, t)]) continue; minimize(ans, cost + calc(u, ed)); // if(t < 2) { for(int &v : g[u]) { if(dp.count(make_pair(v, t + 1)) == 0) { dp[{v, t + 1}] = cost + 1; pq.push({cost + 1, v, t + 1}); } else if(dp[{v, t + 1}] > cost + 1) { dp[{v, t + 1}] = cost + 1; pq.push({cost + 1, v, t + 1}); } } //} } cout << ans << "\n"; } } int main () { ios_base::sync_with_stdio(0); cin.tie(0); #define taskname "kieuoanh" if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } int tc = 1; /// cin >> tc; while (tc--) process(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:94:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...