Submission #101516

# Submission time Handle Problem Language Result Execution time Memory
101516 2019-03-19T03:32:12 Z dantoh000 Adriatic (CEOI13_adriatic) C++14
0 / 100
2000 ms 263168 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> adjlist[n];
    int x[n], y[n];
    for (int i = 0; i < n; i++){
        scanf("%d%d",&x[i],&y[i]);
        for (int j = 0; j < i; j++){
            if ((x[i]<x[j] &&y[i]<y[j]) ||
                (x[i]>y[j] &&y[i]>y[j])){
                adjlist[i].push_back(j);
                adjlist[j].push_back(i);
            }
        }
    }
    int ans = 0;
    int adjmat[n][n];
    memset(adjmat,-1,sizeof(adjmat));
    for (int i = 0; i < n; i++){
        queue<int> q;
        adjmat[i][i] = 0; q.push(i);
        while (q.size()){
            int u = q.front(); q.pop();
            for (auto v : adjlist[u]){
                if (adjmat[i][v] != -1) continue;
                adjmat[i][v] = adjmat[i][u]+1;
                q.push(v);
            }
        }
    }
    for (int i = 0; i < n; i++){
        int sum = 0;
        for (int j = 0; j < n; j++){
            sum += adjmat[i][j];
            //printf("%d ",adjmat[i][j]);
        }
        printf("%d\n",sum);
    }
}

Compilation message

adriatic.cpp: In function 'int main()':
adriatic.cpp:19:9: warning: unused variable 'ans' [-Wunused-variable]
     int ans = 0;
         ^~~
adriatic.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
adriatic.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x[i],&y[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1288 ms 12344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 126336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1664 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1863 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -