제출 #997373

#제출 시각아이디문제언어결과실행 시간메모리
997373doducanhPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms348 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; vector<int>tmp; long long 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'); if(xo==xt){ delt+=abs(a[i].yt-a[i].yo); } else{ tmp.push_back(a[i].yo); tmp.push_back(a[i].yt); v.push_back({a[i].yo,a[i].yt}); } } long long ans=LLONG_MAX; sort(tmp.begin(),tmp.end()); int to=tmp[tmp.size()/2]; long long s=0ll; for(auto [x,y]:v){ s=s+((abs(x-to)+abs(y-to))+1); } ans=min(ans,s); if(tmp.size()/2-1>=0){ to=tmp[tmp.size()/2-1]; s=0ll; for(auto [x,y]:v) { s=s+((abs(x-to)+abs(y-to))+1); } ans=min(ans,s); } if(tmp.size()/2+1<tmp.size()){ to=tmp[tmp.size()/2+1]; s=0ll; for(auto [x,y]:v) { s=s+((abs(x-to)+abs(y-to))+1); } ans=min(ans,s); } cout<<ans+delt; return 0; } /* 1 5 B 0 A 4 B 1 B 3 A 5 B 7 B 2 A 6 B 1 A 7 */

컴파일 시 표준 에러 (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:36:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   36 |     for(auto [x,y]:v){
      |              ^
bridge.cpp:43:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |         for(auto [x,y]:v)
      |                  ^
bridge.cpp:52:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |         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...