# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101465 | cheeheng | Adriatic (CEOI13_adriatic) | C++14 | 2062 ms | 231916 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |