답안 #53245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
53245 2018-06-29T05:31:16 Z 노영훈(#1400) 섬 항해 (CEOI13_adriatic) C++11
25 / 100
2000 ms 25148 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;

bool G[MX][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=1; x<=n; x++)
            if(G[v][x] && 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++)
            G[i][j]=G[j][i]=valid(P[i], P[j]);

    for(int i=1; i<=n; i++)
        cout<<solve(i)<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 10 ms 868 KB Output is correct
3 Correct 7 ms 948 KB Output is correct
4 Correct 9 ms 948 KB Output is correct
5 Correct 7 ms 948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2061 ms 7956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 25148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 25148 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 25148 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -