# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25641 | 2017-06-23T10:09:09 Z | Extazy | 섬 항해 (CEOI13_adriatic) | C++14 | 2000 ms | 198412 KB |
#include <bits/stdc++.h> using namespace std; const int N = 7000; const int INF = (1e9) + 7; pair < int, int > a[N]; int get_dist(pair < int, int > a, pair < int, int > b){ return abs(a.first-b.first)+abs(a.second-b.second); } struct cmp { pair < int, int > d; cmp(){} cmp(pair < int, int > a) { d=a; } bool operator ()(const int &x, const int &y) const { return get_dist(a[x],d)<get_dist(a[y],d); } }; int 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++) { sort(v[i].begin(),v[i].end(),cmp(a[i])); } for(i=1;i<=n;i++) { while(v[i].size()>300) v[i].pop_back(); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 193656 KB | Output is correct |
2 | Correct | 0 ms | 193656 KB | Output is correct |
3 | Correct | 0 ms | 193656 KB | Output is correct |
4 | Correct | 0 ms | 193656 KB | Output is correct |
5 | Correct | 0 ms | 193656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 449 ms | 194316 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2000 ms | 198412 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 193656 KB | Execution killed because of forbidden syscall futex (202) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 193656 KB | Execution killed because of forbidden syscall futex (202) |
2 | Halted | 0 ms | 0 KB | - |