# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
872034 |
2023-11-12T07:14:23 Z |
Matjaz |
Ideal city (IOI12_city) |
C++14 |
|
1000 ms |
262144 KB |
#include<algorithm>
#include <vector>
#include <stdlib.h>
#include <iostream>
using namespace std;
int DistanceSum(int N, int *X, int *Y) {
vector<vector<int> > d(N, vector<int>(N, N +2));
for (int i=0;i<N;i++){
for (int j=0;j<N;j++){
if (abs(X[i] - X[j]) + abs(Y[i] - Y[j]) <= 1) d[i][j] = abs(X[i] - X[j]) + abs(Y[i] - Y[j]);
}
}
long long M = 1000000000;
long long sum = 0;
for (int k=0;k<N;k++){
for (int i=0;i<N;i++){
for (int j=0;j<N;j++){
if (d[i][k] + d[k][j] < d[i][j]){
d[i][j] = d[i][k] + d[k][j];
}
}
}
}
/*for (int i=0;i<N;i++){
for (int j=i+1;j<N;j++) cout << i << " " << j << " " << d[i][j] << endl;
} */
for (int i=0;i<N;i++){
for (int j=i+1;j<N;j++) sum = (sum + d[i][j]) % M;
}
return sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
8 ms |
576 KB |
Output is correct |
7 |
Correct |
8 ms |
604 KB |
Output is correct |
8 |
Correct |
8 ms |
604 KB |
Output is correct |
9 |
Correct |
11 ms |
608 KB |
Output is correct |
10 |
Correct |
13 ms |
576 KB |
Output is correct |
11 |
Correct |
9 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1018 ms |
4384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
106 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
102 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |