Submission #107003

#TimeUsernameProblemLanguageResultExecution timeMemory
107003someone_aaPalembang Bridges (APIO15_bridge)C++17
22 / 100
203 ms7896 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 100100; ll s[maxn], f[maxn], n, k; char szone[maxn], fzone[maxn]; int main() { cin>>k>>n; ll result = 0LL; vector<ll>v; vector<pair<ll,ll> > vv; for(int i=1;i<=n;i++) { cin>>szone[i]>>s[i]; cin>>fzone[i]>>f[i]; if(szone[i] == fzone[i]) result += abs(f[i] - s[i]); if(szone[i] != fzone[i]) { v.pb(s[i]); v.pb(f[i]); } vv.pb(mp(min(s[i], f[i]), max(s[i], f[i]))); } if(v.size() == 0) { cout<<result; return 0; } if(k == 1) { ll mintemp = LLONG_MAX; sort(v.begin(), v.end()); // 0 1 2 3 int half = v[0]; if(v.size() > 1) half = v[v.size()/2-1]; else half = v.back(); for(int d=half-1;d<=half+1;d++) { ll temp = 0LL; for(int i=1;i<=n;i++) { if(szone[i] != fzone[i]) { temp += abs(f[i] - d) + abs(s[i] - d) + 1; } } //cout<<d<<": "<<temp<<"\n"; mintemp = min(mintemp, temp); } result += mintemp; cout<<result<<"\n"; return 0; } else if(k == 2) { for(int i:v) { } } return 0; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:58:17: warning: unused variable 'i' [-Wunused-variable]
         for(int i:v) {
                 ^
#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...