#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
int x[n], y[n];
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
int am[n][n];
memset(am, -1, sizeof am);
for (int i = 0; i < n; ++i) am[i][i] = 0;
for (int i = 0; i < n; ++i) {
for (int j = i+1; j < n; ++j) {
if ((x[i] < x[j] && y[i] < y[j]) || (x[j] < x[i] && y[j] < y[i]))
am[i][j] = am[j][i] = 1;
}
}
for (int k = 0; k < n; ++k) {
for (int i = 0; i < n; ++i) if (am[i][k] != -1) {
for (int j = 0; j < n; ++j) if (am[k][j] != -1) {
if (am[i][j] == -1 || am[i][k] + am[k][j] < am[i][j])
am[i][j] = am[i][k]+am[k][j];
}
}
}
for (int i = 0; i < n; ++i) {
int ans = 0;
for (int j = 0; j < n; ++j) ans += am[i][j];
cout << ans << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2029 ms |
9216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2045 ms |
98296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
214 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
63 ms |
6752 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |