Submission #61843

#TimeUsernameProblemLanguageResultExecution timeMemory
61843zetapiIdeal city (IOI12_city)C++14
Compilation error
0 ms0 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; set<ll> adj[MAX]; ll res,value[MAX],sum[MAX]; void dfs(int node,int par) { sum[node]=value[node]; for(auto A:adj[node]) { if(A==par) continue; dfs(A,node); sum[node]+=sum[A]; sum[node]%=mod; } return ; } void dfs_(int node,int par) { for(auto A:adj[node]) { if(A==par) continue; dfs_(A,node); res+=(sum[A]*(sum[1]-sum[A]+mod)%mod)%mod; res%=mod; } return ; } void cal(int N,int *X,int *Y) { for(int A=1;A<=N;A++) { sum[A]=0; value[A]=0; adj[A].clear(); } int ptr=0; vector<pii> vec; map<pii,int> mark; for(int A=0;A<N;A++) vec.pb(mp(X[A],Y[A])); vec.pb(mp(0,0)); sort(vec.begin(),vec.end()); for(int A=1;A<vec.size();A++) { if(vec[A].first==vec[A-1].first and vec[A].second==vec[A-1].second+1) { value[ptr]++; mark[mp(vec[A].first,vec[A].second)]=ptr; } else { value[++ptr]++; mark[mp(vec[A].first,vec[A].second)]=ptr; } //cout<<vec[A].first<<" "<<vec[A].second<<" "<<mark[vec[A]]<<"\n"; } for(int A=1;A<vec.size();A++) { if(mark[mp(vec[A].first-1,vec[A].second)]) { adj[mark[vec[A]]].insert(mark[mp(vec[A].first-1,vec[A].second)]); adj[mark[mp(vec[A].first-1,vec[A].second)]].insert(mark[vec[A]]); // cout<<mark[vec[A]]<<" "<<mark[mp(vec[A].first-1,vec[A].second)]<<"lol \n"; } } dfs(1,0); dfs_(1,0); return ; } int DistanceSum(int N, int *X, int *Y) { cal(N,X,Y); for(int A=0;A<N;A++) swap(X[A],Y[A]); cal(N,X,Y); return res; } signed main() { ios_base::sync_with_stdio(false); int X[]={2,2,3,3,4,4,4,4,5,5,5}; int Y[]={5,6,3,6,3,4,5,6,3,4,6}; cout<<DistanceSum(11,X,Y); return 0; }

Compilation message (stderr)

city.cpp: In function 'void cal(int, int*, int*)':
city.cpp:62:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=1;A<vec.size();A++)
              ~^~~~~~~~~~~
city.cpp:76:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=1;A<vec.size();A++)
              ~^~~~~~~~~~~
/tmp/cc5r5njY.o: In function `main':
city.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccGWs9Zf.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status