# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25632 | 2017-06-23T09:20:13 Z | Extazy | Adriatic (CEOI13_adriatic) | C++14 | 2000 ms | 200540 KB |
#include <bits/stdc++.h> using namespace std; const int N = 7000; const int INF = (1e9) + 7; int n; pair < int, int > a[N]; vector < int > v[N]; bool in[N]; int dist[N][N]; void spfa(int start, int *dist) { int i,curr; queue < int > q; for(i=1;i<=n;i++) dist[i]=INF; memset(in,0,sizeof(in)); dist[start]=0; q.push(start); in[start]=true; while(!q.empty()) { curr=q.front(); in[curr]=false; q.pop(); for(i=0;i<(int)(v[curr].size());i++) { int current_distance=dist[curr]+1; if(dist[v[curr][i]]>current_distance) { dist[v[curr][i]]=current_distance; if(!in[v[curr][i]]) { in[v[curr][i]]=true; q.push(v[curr][i]); } } } } } int main() { int i,j; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d %d", &a[i].first, &a[i].second); } for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { if((a[i].first>a[j].first && a[i].second>a[j].second) || (a[i].first<a[j].first && a[i].second<a[j].second)) { v[i].push_back(j); v[j].push_back(i); } } } for(i=1;i<=n;i++) { random_shuffle(v[i].begin(),v[i].end()); } for(i=1;i<=n;i++) { spfa(i,dist[i]); long long sum=0; for(j=1;j<=n;j++) { sum+=dist[i][j]; } printf("%lld\n", sum); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 193656 KB | Output is correct |
2 | Correct | 3 ms | 193656 KB | Output is correct |
3 | Correct | 0 ms | 193656 KB | Output is correct |
4 | Correct | 3 ms | 193656 KB | Output is correct |
5 | Correct | 0 ms | 193656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 446 ms | 194316 KB | Output is correct |
2 | Execution timed out | 2000 ms | 200540 KB | Execution timed out |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2000 ms | 198412 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1143 ms | 196824 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 276 ms | 194976 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |