Submission #101513

# Submission time Handle Problem Language Result Execution time Memory
101513 2019-03-19T03:29:50 Z dwsc Adriatic (CEOI13_adriatic) C++14
25 / 100
2000 ms 263168 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
    int n;
    cin >> n;
    ii arr[n];
    vector<int> adj[n];
    for (int i = 0; i < n; i++){
        cin >> arr[i].first >> arr[i].second;
        for (int j = 0; j < i; j++){
            if ((arr[j].first<arr[i].first)&&(arr[j].second<arr[i].second)||(arr[j].first>arr[i].first)&&(arr[j].second>arr[i].second)){
                adj[j].push_back(i);
                adj[i].push_back(j);
               // cout<< i <<  " " << j << "hi\n";
            }
        }
    }
    for (int i = 0; i < n; i++){
        queue<int> q;
        q.push(i);
        int dist[n];
        memset(dist,-1,sizeof(dist));
        dist[i] = 0;
        int sum = 0;
        while (!q.empty()){
            int u = q.front();
            q.pop();
            for (int i = 0; i < adj[u].size(); i++){
                int v = adj[u][i];
                if (dist[v] == -1){
                    dist[v] = dist[u]+1;
                    sum += dist[v];
                    q.push(v);
                }
            }
        }
        cout << sum << "\n";
    }
}

Compilation message

adriatic.cpp: In function 'int main()':
adriatic.cpp:12:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
             if ((arr[j].first<arr[i].first)&&(arr[j].second<arr[i].second)||(arr[j].first>arr[i].first)&&(arr[j].second>arr[i].second)){
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adriatic.cpp:29:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < adj[u].size(); i++){
                             ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 284 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 318 ms 1080 KB Output is correct
2 Execution timed out 2045 ms 6808 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 5008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 203224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1410 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -