Submission #997355

#TimeUsernameProblemLanguageResultExecution timeMemory
997355doducanhPalembang Bridges (APIO15_bridge)C++14
0 / 100
4 ms480 KiB
#include <bits/stdc++.h> using namespace std; #define ii pair<int,int> const int maxn=1e5+7; struct nguoi { int xo,yo,xt,yt; }; nguoi a[maxn]; int k,n; main() { cin>>k>>n; vector<ii>v; set<int>s; int delt=0; for(int i=1;i<=n;i++){ char xo,xt; cin>>xo>>a[i].yo>>xt>>a[i].yt; a[i].xo=(xo=='B'); a[i].xt=(xt=='B'); s.insert(a[i].yo); s.insert(a[i].yt); if(xo==xt){ delt+=abs(a[i].yt-a[i].yo); } else v.push_back({a[i].yo,a[i].yt}); } long long ans=1e18+7; for(int to:s){ long long s=0; for(auto [x,y]:v){ s=s+((long long)(abs(x-to)+abs(y-to))+1); } ans=min(ans,s); } cout<<ans+delt; return 0; }

Compilation message (stderr)

bridge.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      | ^~~~
bridge.cpp: In function 'int main()':
bridge.cpp:33:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         for(auto [x,y]: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...