Submission #101442

# Submission time Handle Problem Language Result Execution time Memory
101442 2019-03-19T02:06:17 Z rainy Adriatic (CEOI13_adriatic) C++14
25 / 100
2000 ms 208180 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 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++){
        int ds[N+5];
        queue<int>q;q.push(i);
        bool vis[25005]={false};
        vis[i]=true;
        ds[i]=0;
        while(!q.empty()){
            int pp=q.front();q.pop();
            int st=ds[pp];
            for(auto&p2:al[pp]){
                if(!vis[p2]){
                    vis[p2]=true;
                    ds[p2]=st+1;
                    q.push(p2);
                }
            }
        }

        int ans=0;
        for(int j=0;j<N;j++){
            ans+=ds[j];
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compilation message

adriatic.cpp: In function 'int main()':
adriatic.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
adriatic.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&X,&Y);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 4 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 294 ms 1664 KB Output is correct
2 Execution timed out 2017 ms 7928 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 5920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2057 ms 208180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 426 ms 4176 KB Output isn't correct
2 Halted 0 ms 0 KB -