Submission #767701

# Submission time Handle Problem Language Result Execution time Memory
767701 2023-06-27T04:54:39 Z 79brue Adriatic (CEOI13_adriatic) C++17
25 / 100
2000 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Point{
    int x, y;
    Point(){}
    Point(int x, int y): x(x), y(y){}

    bool operator<(const Point &r)const{
        return x<r.x;
    }
};

int n;
Point arr[250002];
vector<int> link[250002];
int dist[5002][5002];
bool visited[5002];
ll ans[250002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d %d", &arr[i].x, &arr[i].y);
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(i==j) continue;
            if((arr[i].x < arr[j].x && arr[i].y < arr[j].y) || (arr[i].x > arr[j].x && arr[i].y > arr[j].y)){
                link[i].push_back(j);
                link[j].push_back(i);
            }
        }
    }
    for(int i=1; i<=n; i++){
        memset(visited, 0, sizeof(visited));
        queue<int> que;
        que.push(i);
        visited[i] = 1;
        while(!que.empty()){
            int x = que.front(); que.pop();
            for(auto y: link[x]){
                if(visited[y]) continue;
                dist[i][y] = dist[i][x] + 1;
                visited[y] = 1;
                que.push(y);
            }
        }
        for(int j=1; j<=n; j++) ans[i] += dist[i][j];
        printf("%lld\n", ans[i]);
    }
}

Compilation message

adriatic.cpp: In function 'int main()':
adriatic.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
adriatic.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d %d", &arr[i].x, &arr[i].y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6700 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6612 KB Output is correct
5 Correct 3 ms 6644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 22372 KB Output is correct
2 Execution timed out 2072 ms 31884 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 47968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1709 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1048 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -