# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
912826 | 2024-01-20T02:18:29 Z | Muhammad_Aneeq | Ideal city (IOI12_city) | C++17 | 44 ms | 7792 KB |
#include <cmath> #include <vector> #include <map> #include <algorithm> using namespace std; int const MAXN=1e5+10; vector<int>nei[MAXN]={}; int mod=1e9; int DistanceSum(int N, int X[], int Y[]) { int ans=0; map<int,vector<int>>d; for (int i=0;i<N;i++) d[X[i]].push_back(Y[i]); bool subtask_3=1; for (auto& i:d) { sort(begin(i.second),end(i.second)); if (i.second.size()!=i.second.back()-i.second[0]+1) { subtask_3=0; break; } } if (subtask_3) { sort(Y,Y+N); sort(X,X+N); int ans=0; long long szx=0,sux=0,szy=0,suy=0; for (int i=0;i<N;i++) { long long g=1ll*Y[i]*szy-suy; g%=mod; ans=(ans+g)%mod; g=1ll*X[i]*szx-sux; g%=mod; ans=(ans+g)%mod; szy++; suy+=Y[i]; szx++; sux+=X[i]; } return ans; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2908 KB | Output is correct |
2 | Correct | 7 ms | 3364 KB | Output is correct |
3 | Correct | 17 ms | 3976 KB | Output is correct |
4 | Correct | 17 ms | 3932 KB | Output is correct |
5 | Correct | 31 ms | 5212 KB | Output is correct |
6 | Correct | 33 ms | 4948 KB | Output is correct |
7 | Correct | 34 ms | 5204 KB | Output is correct |
8 | Correct | 31 ms | 5092 KB | Output is correct |
9 | Correct | 35 ms | 4948 KB | Output is correct |
10 | Correct | 44 ms | 7792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 2908 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |