# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
280472 | 2020-08-22T19:51:36 Z | ElyesChaabouni | Ideal city (IOI12_city) | C++14 | 1000 ms | 2900 KB |
#pragma GCC optimize("O3") #include<bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> #define eps 1e-9 #define MOD1 998244353 #define MOD2 1000000007 #define INV_10 299473306 #define INF 1000000000 #define PI 3.14159265358979323846 using namespace std; int DistanceSum(int N, int *X, int *Y) { vector<int>v[N]; for(int j = 0; j < N; j++) { for(int k = j+1; k< N; k++) { long long x1=abs(X[j]-X[k]), y1=abs(Y[j]-Y[k]); long long dis=x1+y1; if(dis==1) { v[k].push_back(j); v[j].push_back(k); } } } long long ans=0; for(int i = 0; i < N; i++) { //cout << i << ' ' << X[i] << ' ' << Y[i] << '\n'; unordered_set<int>s; int nb=1, idx=0; vector<int>bfs; bfs.push_back(i); bool ok=1; s.insert(i); while(bfs.size()!=N) { //cout << nb << '\n'; int l=bfs.size(); for(int j = idx; j < l; j++) { //cout << bfs[j].first << ' ' << bfs[j].second << '\n'; for(int k = 0; k < v[bfs[j]].size(); k++) { if(!s.count(v[bfs[j]][k])) { s.insert(v[bfs[j]][k]); if(v[bfs[j]][k] < i) ans+=nb; bfs.push_back(v[bfs[j]][k]); } } } nb++; idx=l; } ans%= 1000000000; } //ans*=( 1000000000); ans%= 1000000000; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 8 ms | 384 KB | Output is correct |
7 | Correct | 8 ms | 384 KB | Output is correct |
8 | Correct | 7 ms | 384 KB | Output is correct |
9 | Correct | 7 ms | 384 KB | Output is correct |
10 | Correct | 8 ms | 384 KB | Output is correct |
11 | Correct | 8 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 166 ms | 476 KB | Output is correct |
2 | Correct | 173 ms | 384 KB | Output is correct |
3 | Correct | 347 ms | 632 KB | Output is correct |
4 | Correct | 383 ms | 632 KB | Output is correct |
5 | Correct | 658 ms | 632 KB | Output is correct |
6 | Correct | 709 ms | 620 KB | Output is correct |
7 | Correct | 659 ms | 632 KB | Output is correct |
8 | Correct | 700 ms | 632 KB | Output is correct |
9 | Correct | 712 ms | 512 KB | Output is correct |
10 | Correct | 707 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1093 ms | 2900 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 2796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |