Submission #61396

#TimeUsernameProblemLanguageResultExecution timeMemory
61396zetapiIdeal city (IOI12_city)C++14
23 / 100
65 ms9424 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator typedef pair<ll,ll> pii; const ll MAX=1e6; const ll mod=1e9; vector<pii> vec; ll pre[MAX]; ll cal(vector<ll> arr) { ll sum=0,res=0; for(int A=1;A<arr.size();A++) pre[A]=(pre[A-1]+arr[A])%mod; for(int A=1;A<arr.size();A++) { res+=(sum*arr[A])%mod; res%=mod; sum+=pre[A]; sum%=mod; } return res; } int DistanceSum(int N, int *X, int *Y) { vector<ll> arr; ll res=0,cur,lol; for(int A=0;A<N;A++) vec.pb(mp(X[A],Y[A])); sort(vec.begin(),vec.end()); cur=0; arr.pb(0); while(cur<vec.size()) { lol=vec[cur].second; while(cur+1<vec.size() and vec[cur+1].first==vec[cur].first) ++cur; arr.pb(vec[cur].second-lol+1); ++cur; } //for(auto A:arr) // cout<<A<<" ha ha\n"; res=cal(arr); for(int A=0;A<N;A++) swap(vec[A].first,vec[A].second); sort(vec.begin(),vec.end()); arr.clear(); arr.pb(0); cur=0; while(cur<vec.size()) { lol=vec[cur].second; while(cur+1<vec.size() and vec[cur+1].first==vec[cur].first) ++cur; arr.pb(vec[cur].second-lol+1); ++cur; } //for(auto A:arr) // cout<<A<<" o "; res+=cal(arr); res%=mod; return res; } /*signed main() { ios_base::sync_with_stdio(false); int X[]={1,1,2,2}; int Y[]={1,2,1,2}; cout<<DistanceSum(4,X,Y); return 0; }*/

Compilation message (stderr)

city.cpp: In function 'long long int cal(std::vector<long long int>)':
city.cpp:21:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=1;A<arr.size();A++)
              ~^~~~~~~~~~~
city.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=1;A<arr.size();A++)
              ~^~~~~~~~~~~
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:42:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(cur<vec.size())
        ~~~^~~~~~~~~~~
city.cpp:45:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(cur+1<vec.size() and vec[cur+1].first==vec[cur].first)
         ~~~~~^~~~~~~~~~~
city.cpp:59:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(cur<vec.size())
        ~~~^~~~~~~~~~~
city.cpp:62:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(cur+1<vec.size() and vec[cur+1].first==vec[cur].first)
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...