제출 #585456

#제출 시각아이디문제언어결과실행 시간메모리
585456mnngPalembang Bridges (APIO15_bridge)C++14
0 / 100
5 ms6772 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 = true; }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); } } sort(v.begin(), v.end()); if(k == 1) { ll h = v.size()/2; h = v[h]; 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(false); cin.tie(nullptr); Input(); }
#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...