Submission #280438

#TimeUsernameProblemLanguageResultExecution timeMemory
280438ElyesChaabouniIdeal city (IOI12_city)C++14
0 / 100
1093 ms2316 KiB
/*#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 inc[4][2]={{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; int DistanceSum(int N, int *X, int *Y) { long long ans=0; for(int i = 0; i < N; i++) { set<pair<int, int> >s; for(int j = 0; j < N; j++) { if(j!=i) { s.insert(make_pair(X[j], Y[j])); } } int nb=0, idx=0; vector<pair<int, int> >bfs; bfs.push_back(make_pair(X[i], Y[i])); while(!s.empty()) { int l=bfs.size(); for(int j = idx; j < l; j++) { ans+=nb; ans%=MOD2; for(int k = 0; k < 4; k++) { int xx=bfs[j].first+inc[k][0], yy=bfs[j].second+inc[k][1]; if(s.count(make_pair(xx, yy))) { s.erase(make_pair(xx, yy)); bfs.push_back(make_pair(xx, yy)); } } } nb++; idx=l; } } ans*=(500000004); ans%=MOD2; return ans; } //size
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...