# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101620 | dantoh000 | Adriatic (CEOI13_adriatic) | C++14 | 2044 ms | 263168 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;
typedef pair<int,int> ii;
int main(){
int n;
scanf("%d",&n);
int adjmat[n][n];
memset(adjmat,-1,sizeof(adjmat));
int x[n], y[n];
for (int i = 0; i < n; i++){
adjmat[i][i] = 0;
scanf("%d%d",&x[i],&y[i]);
for (int j = 0; j < i; j++){
if ((x[i]<x[j]&&y[i]<y[j]) ||
(x[i]>x[j]&&y[i]>y[j])){
//printf("%d %d con\n",i,j);
adjmat[i][j] = adjmat[j][i] = 1;
}
}
}
int ans = 0;
for (int k = 0; k < n; k++){
for (int i = 0; i < n; i++){
if (adjmat[i][k] == -1) continue;
for (int j = i+1; j < n; j++){
if (adjmat[k][j] == -1) continue;
if (adjmat[i][j]==-1) adjmat[j][i] = adjmat[i][j] = adjmat[i][k]+adjmat[k][j];
else adjmat[j][i] = adjmat[i][j] = min(adjmat[i][j],adjmat[i][k]+adjmat[k][j]);
}
}
}
for (int i = 0 ;i <n; i++){
int ans = 0;
for (int j = 0; j < n; j++){
//printf("%d ",adjmat[i][j]);
ans += adjmat[i][j];
}
printf("%d\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... |