# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
141740 | admin | Adriatic (CEOI13_adriatic) | C++14 | 2068 ms | 197624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
#include<cassert>
#include<vector>
#include<queue>
#define pb push_back
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>vi;
int N,X,Y;
ii loc[25005];
vi al[25005];
int apsp[5005][5005];
int main(){
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d%d",&X,&Y);
loc[i]=ii(X,Y);
}
for(int i=0;i<N;i++){
int x1=loc[i].first,y1=loc[i].second;
for(int j=i+1;j<N;j++){
int x2=loc[j].first,y2=loc[j].second;
if((x1<x2&&y1<y2)||(x1>x2&&y1>y2)){
al[i].pb(j);al[j].pb(i);
}
}
}
for(int i=0;i<N;i++){
queue<int>q;q.push(i);
assert(al[i].size() == N-1);
bool vis[25005]={false};
vis[i]=true;
apsp[i][i]=0;
while(!q.empty()){
int pp=q.front();q.pop();
int st=apsp[i][pp];
for(auto&p2:al[pp]){
if(!vis[p2]){
vis[p2]=true;
apsp[i][p2]=st+1;
q.push(p2);
}
}
}
}
for(int i=0;i<N;i++){
int ans=0;
for(int j=0;j<N;j++){
ans+=apsp[j][i];
}
printf("%d\n",ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |