제출 #585451

#제출 시각아이디문제언어결과실행 시간메모리
585451messiuuuuuPalembang Bridges (APIO15_bridge)C++17
22 / 100
43 ms4300 KiB
#include<bits/stdc++.h> #define task "A" #define ll long long #define ld long double #define fi first #define se second #define pb push_back using namespace std; const int MAXN = 1e5 + 5; const ll INF = 1e18 + 5; int n, k; struct TRoad { char h, o; ll ph, po; }a[MAXN]; void Input() { cin >> k >> n; for (int i = 1; i <= n; i++) { cin >> a[i].h >> a[i].ph >> a[i].o >> a[i].po; } } ll Cal(int p) { ll res = 0; for (int i = 1; i <= n; i++) { if (a[i].h == a[i].o) { res += abs(a[i].ph - a[i].po); } else { res += abs(a[i].ph - p) + abs(a[i].po - p) + 1; } } return res; } void Solve() { int l = 0, r = 1e9; while (l <= r) { int mid = (l + r) / 2; if (mid == n) break; if (Cal(mid) >= Cal(mid + 1)) l = mid + 1; else r = mid - 1; } cout << Cal(l); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(task".INP","r")) { freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } Input(); Solve(); }

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

bridge.cpp: In function 'int main()':
bridge.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...