# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
53246 |
2018-06-29T05:33:29 Z |
노영훈(#1400) |
섬 항해 (CEOI13_adriatic) |
C++11 |
|
2000 ms |
4220 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=5010, inf=2e9;
// 격자 2500!!
struct pt {
int x, y, idx;
} P[MX];
int n;
vector<uint16_t> G[MX];
bool valid(pt &a, pt &b){
return (a.x-b.x)*(a.y-b.y)>0;
}
ll solve(int s){
ll ans=0;
queue<int> Q;
int D[MX]={};
fill(D, D+n+1, -1);
D[s]=0; Q.push(s);
while(!Q.empty()){
int v=Q.front(); Q.pop();
for(int x:G[v])
if(D[x]<0)
D[x]=D[v]+1, Q.push(x);
}
for(int i=1; i<=n; i++) ans+=D[i];
return ans;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=1; i<=n; i++){
int x, y;
cin>>x>>y;
P[i]={x,y,i};
}
for(int i=1; i<=n; i++)
for(int j=i+1; j<=n; j++){
if(valid(P[i], P[j])){
G[i].push_back(j);
G[j].push_back(i);
}
}
for(int i=1; i<=n; i++)
cout<<solve(i)<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
540 KB |
Output is correct |
4 |
Correct |
3 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
1024 KB |
Output is correct |
2 |
Correct |
1485 ms |
4140 KB |
Output is correct |
3 |
Correct |
115 ms |
4140 KB |
Output is correct |
4 |
Correct |
1454 ms |
4220 KB |
Output is correct |
5 |
Correct |
1309 ms |
4220 KB |
Output is correct |
6 |
Correct |
114 ms |
4220 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
4220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
4220 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
4220 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |