답안 #101439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101439 2019-03-19T02:02:01 Z rainy 섬 항해 (CEOI13_adriatic) C++14
50 / 100
2000 ms 205804 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
#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);
        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

adriatic.cpp: In function 'int main()':
adriatic.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
adriatic.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&X,&Y);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1408 KB Output is correct
2 Correct 4 ms 1408 KB Output is correct
3 Correct 4 ms 1408 KB Output is correct
4 Correct 4 ms 1408 KB Output is correct
5 Correct 4 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 294 ms 16540 KB Output is correct
2 Correct 1553 ms 22712 KB Output is correct
3 Correct 162 ms 15992 KB Output is correct
4 Correct 1929 ms 22732 KB Output is correct
5 Correct 1625 ms 22068 KB Output is correct
6 Correct 135 ms 16120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2041 ms 42448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2043 ms 205804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 496 ms 12004 KB Output isn't correct
2 Halted 0 ms 0 KB -