Submission #106998

#TimeUsernameProblemLanguageResultExecution timeMemory
106998someone_aaPalembang Bridges (APIO15_bridge)C++17
0 / 100
2 ms384 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(k == 1) { ll mintemp = LLONG_MAX; sort(v.begin(), v.end()); for(int x=v.size()/2-1;x<v.size()/2+1;x++) { int i = v[x]; ll temp = 0LL; for(int j=1;j<=n;j++) { if(szone[j] != fzone[j]) { temp += abs(s[j] - i) + abs(f[j] - i) + 1; } } mintemp = min(mintemp, temp); //cout<<i<<": "<<temp<<"\n"; } 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:30:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int x=v.size()/2-1;x<v.size()/2+1;x++) {
                                ~^~~~~~~~~~~~~
bridge.cpp:46: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...