제출 #585449

#제출 시각아이디문제언어결과실행 시간메모리
585449tamthegodPalembang Bridges (APIO15_bridge)C++14
8 / 100
2049 ms8828 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 1e6 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int k, n; int res = 0; int m = 0; vector<int> vc; struct TCitizen { char p; int s; char q; int t; } a[maxN]; void ReadInput() { cin >> k >> n; for(int i=1; i<=n; i++) { char p, q; int s, t; cin >> p >> s >> q >> t; vc.pb((s + t) / 2); if(p == q) { res += abs(s - t); continue; } vc.pb(s); vc.pb(t); if(s > t) swap(s, t); a[++m] = {p, s, q, t}; } } void Solve() { assert(k == 1); int _min = oo; sort(vc.begin(), vc.end()); vc.erase(unique(vc.begin(), vc.end()), vc.end()); sort(a + 1, a + m + 1, [](TCitizen p, TCitizen q) { return p.t < q.t; }); int p = 1; int mid = vc.size() / 2; for(int x : vc) { // int x = vc[i]; int val = 0; for(int i=1; i<=m; i++) val += abs(x - a[i].s) + abs(x - a[i].t) + 1; _min = min(_min, val); } cout << res + _min; } int32_t main() { // freopen("x.inp", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(nullptr); ReadInput(); Solve(); }

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

bridge.cpp: In function 'void Solve()':
bridge.cpp:56:9: warning: unused variable 'p' [-Wunused-variable]
   56 |     int p = 1;
      |         ^
bridge.cpp:57:9: warning: unused variable 'mid' [-Wunused-variable]
   57 |     int mid = vc.size() / 2;
      |         ^~~
#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...