답안 #101512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101512 2019-03-19T03:29:49 Z dantoh000 섬 항해 (CEOI13_adriatic) C++14
25 / 100
2000 ms 255560 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
    int n;
    scanf("%d",&n);
    unordered_set<int> adjlist[n];
    vector<ii> co(n);
    for (int i = 0; i < n; i++){
        scanf("%d%d",&co[i].first,&co[i].second);
        for (int j = 0; j < i; j++){
            if ((co[i].first < co[j].first && co[i].second < co[j].second) ||
                (co[i].first > co[j].first && co[i].second > co[j].second)){
                adjlist[i].insert(j);
                adjlist[j].insert(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",&co[i].first,&co[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 13788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 130400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 186912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 255560 KB Time limit exceeded
2 Halted 0 ms 0 KB -