답안 #101465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101465 2019-03-19T02:46:27 Z cheeheng 섬 항해 (CEOI13_adriatic) C++14
25 / 100
2000 ms 231916 KB
#include <bits/stdc++.h>

using namespace std;

int R[250000];
int C[250000];

int dist[250000];

vector<int> AdjList[250005];

int main(){
    int N;
    scanf("%d", &N);

    for(int i = 0; i < N; i ++){
        scanf("%d%d", &R[i], &C[i]);
    }

    for(int i = 0; i < N; i ++){
        for(int j = i+1; j < N; j ++){
            if((R[i] < R[j] && C[i] < C[j]) || (R[i] > R[j] && C[i] > C[j])){
                AdjList[i].push_back(j);
                AdjList[j].push_back(i);
            }
        }
    }

    for(int i = 0; i < N; i ++){
        long long ans = 0;
        memset(dist, -1, sizeof(dist));
        queue<int> q;
        q.push(i);
        dist[i] = 0;
        while(!q.empty()){
            int u = q.front(); q.pop();
            for(int v: AdjList[u]){
                if(dist[v] == -1){
                    dist[v] = dist[u] + 1;
                    q.push(v);
                }
            }
        }
        for(int j = 0; j < N; j ++){
            ans += dist[j];
        }
        printf("%lld\n", ans);
    }
}

Compilation message

adriatic.cpp: In function 'int main()':
adriatic.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
adriatic.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &R[i], &C[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7140 KB Output is correct
2 Correct 15 ms 7296 KB Output is correct
3 Correct 13 ms 7168 KB Output is correct
4 Correct 14 ms 7268 KB Output is correct
5 Correct 13 ms 7168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 413 ms 7940 KB Output is correct
2 Execution timed out 2047 ms 14140 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2011 ms 12016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2062 ms 231916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2052 ms 130048 KB Time limit exceeded
2 Halted 0 ms 0 KB -