Submission #280447

#TimeUsernameProblemLanguageResultExecution timeMemory
280447ElyesChaabouniIdeal city (IOI12_city)C++14
11 / 100
1092 ms2424 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++) { //cout << i << ' ' << X[i] << ' ' << Y[i] << '\n'; map<pair<int, int>, int>m; for(int j = 0; j < N; j++) { if(j!=i) { m[make_pair(X[j], Y[j])]=j; } else { m[make_pair(X[j], Y[j])]=-1; } } int nb=1, idx=0; vector<pair<int, int> >bfs; bfs.push_back(make_pair(X[i], Y[i])); bool ok=1; 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 < 4; k++) { int xx=bfs[j].first+inc[k][0], yy=bfs[j].second+inc[k][1]; if(m.count(make_pair(xx, yy)) && m[make_pair(xx, yy)]!=-1) { if(m[make_pair(xx, yy)] < i) { ans+=nb; ans%=1000000000; } m[make_pair(xx, yy)]=-1; bfs.push_back(make_pair(xx, yy)); } } } nb++; idx=l; } } //ans*=( 1000000000); ans%= 1000000000; return ans; }

Compilation message (stderr)

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:36:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   while(bfs.size()!=N)
      |         ~~~~~~~~~~^~~
city.cpp:35:8: warning: unused variable 'ok' [-Wunused-variable]
   35 |   bool ok=1;
      |        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...