Submission #585462

#TimeUsernameProblemLanguageResultExecution timeMemory
585462mnngPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int maxN = 1e5+1; int k, n; struct Tbridge { char a, b; ll x, y; bool chk; }p[maxN]; ll ans = 0; void Input() { vector<ll> v; cin >> k >> n; for(int i = 1; i <= n; i++) { cin >> p[i].a >> p[i].x >> p[i].b >> p[i].y; if(p[i].a == p[i].b) { ans += abs(p[i].y - p[i].x); p[i].chk = false; } else { v.pb(p[i].x); v.pb(p[i].y); p[i].chk = true; } } sort(v.begin(), v.end()); if(k == 1) { ll res = (int)v.size() / 2; ll h = v[res]; /* for(int i = 1; i <= n; i++) if(p[i].chk) ans += abs(h - p[i].x) + abs(h - p[i].y) + 1;*/ cout << ans; return; } /* int res = v.size()/3; int h = v[res], h2 = v[res*2]; for(int i = 1; i <= n; i++) if(p[i].chk) ans += min(abs(h - p[i].x) + abs(h - p[i].y) + 1, abs(h2 - p[i].x) + abs(h2 - p[i].y) + 1); cout << ans;*/ } int main() { ios_base::sync_with_stdio(0); cin.tie(0); Input(); }

Compilation message (stderr)

bridge.cpp: In function 'void Input()':
bridge.cpp:38:12: warning: unused variable 'h' [-Wunused-variable]
   38 |         ll h = v[res];
      |            ^
#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...