# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
872035 | 2023-11-12T07:21:54 Z | Matjaz | 이상적인 도시 (IOI12_city) | C++14 | 1000 ms | 2044 KB |
#include<algorithm> #include <vector> #include <stdlib.h> #include <iostream> #include <queue> using namespace std; int DistanceSum(int N, int *X, int *Y) { vector<vector<int> > s(N, vector<int>()); for (int i=0;i<N;i++){ for (int j=i+1;j<N;j++){ if (abs(X[i] - X[j]) + abs(Y[i] - Y[j]) <= 1){ s[i].push_back(j); s[j].push_back(i); } } } long long M = 1000000000; long long sum = 0; for (int i=0;i<N;i++){ vector<int> d(N, N + 1); d[i] = 0; queue<int> Q; Q.push(i); while (!Q.empty()){ int x = Q.front(); Q.pop(); for (int i=0;i<s[x].size();i++){ if (d[s[x][i]] > d[x] + 1){ d[s[x][i]] = d[x] + 1; Q.push(s[x][i]); } } } for (int j=i+1;j<N;j++) sum = (sum + d[j]) % M; } return sum; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 600 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 512 KB | Output is correct |
2 | Correct | 22 ms | 516 KB | Output is correct |
3 | Correct | 52 ms | 856 KB | Output is correct |
4 | Correct | 62 ms | 348 KB | Output is correct |
5 | Correct | 90 ms | 348 KB | Output is correct |
6 | Correct | 96 ms | 348 KB | Output is correct |
7 | Correct | 94 ms | 348 KB | Output is correct |
8 | Correct | 100 ms | 568 KB | Output is correct |
9 | Correct | 97 ms | 348 KB | Output is correct |
10 | Correct | 92 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1018 ms | 2044 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1022 ms | 1816 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |