제출 #628198

#제출 시각아이디문제언어결과실행 시간메모리
628198andrei_boaca섬 항해 (CEOI13_adriatic)C++14
50 / 100
2074 ms12560 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; int n; vector<int> muchii[250005]; int my[250005][5]; struct point { int x,y; } v[250005]; ll dist[250005]; priority_queue<pii,vector<pii>,greater<pii>> coada; void bfs(int start) { for(int i=1;i<=n;i++) dist[i]=1e9; dist[start]=0; coada.push({0,start}); while(!coada.empty()) { int nod=coada.top().second; coada.pop(); for(int i:muchii[nod]) if(dist[i]>dist[nod]+1) { dist[i]=dist[nod]+1; coada.push({dist[i],i}); } } } int sol[250005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i=1;i<=n;i++) cin>>v[i].x>>v[i].y; for(int i=1;i<=n;i++) { int linmin=1e9,linmax=0,colmin=1e9,colmax=0; for(int j=1;j<=n;j++) if(j!=i) { bool ok=0; if(i==7) ok=1; if(v[i].x<v[j].x&&v[i].y<v[j].y) { if(v[j].x<linmin) { linmin=v[j].x; my[i][1]=j; } if(v[j].x>linmax) { linmax=v[j].x; my[i][2]=j; } if(v[j].y<colmin) { colmin=v[j].y; my[i][3]=j; } if(v[j].y>colmax) { colmax=v[j].y; my[i][4]=j; } } else if(v[i].x>v[j].x&&v[i].y>v[j].y) { if(v[j].x<linmin) { linmin=v[j].x; my[i][1]=j; } if(v[j].x>linmax) { linmax=v[j].x; my[i][2]=j; } if(v[j].y<colmin) { colmin=v[j].y; my[i][3]=j; } if(v[j].y>colmax) { colmax=v[j].y; my[i][4]=j; } } } } /*for(int i=1;i<=4;i++) cout<<my[7][i]<<' '; cout<<'\n';*/ for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) muchii[j].clear(); for(int j=1;j<=n;j++) { if(v[i].x<v[j].x&&v[i].y<v[j].y) { muchii[i].push_back(j); muchii[j].push_back(i); } else if(v[i].x>v[j].x&&v[i].y>v[j].y) { muchii[i].push_back(j); muchii[j].push_back(i); } } for(int j=1;j<=n;j++) if(j!=i) { for(int k=1;k<=4;k++) { int nod=my[j][k]; muchii[nod].push_back(j); muchii[j].push_back(nod); } } bfs(i); ll suma=0; for(int j=1;j<=n;j++) suma+=dist[j]; cout<<suma<<'\n'; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

adriatic.cpp: In function 'int main()':
adriatic.cpp:47:22: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   47 |                 bool ok=0;
      |                      ^~
#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...