답안 #141740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141740 2019-08-09T01:12:27 Z admin 섬 항해 (CEOI13_adriatic) C++14
0 / 100
2000 ms 197624 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
#include<cassert>
#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);
      assert(al[i].size() == N-1);
        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

In file included from /usr/include/c++/7/cassert:44:0,
                 from adriatic.cpp:5:
adriatic.cpp: In function 'int main()':
adriatic.cpp:35:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       assert(al[i].size() == N-1);
              ~~~~~~~~~~~~~^~~~~~
adriatic.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
adriatic.cpp:21: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 Runtime error 9 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 9 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 8 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 9 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 9 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 3148 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 42 ms 15708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 16 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 42 ms 15452 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 40 ms 14456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 17 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 11384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2068 ms 197624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 8568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -