Submission #487701

#TimeUsernameProblemLanguageResultExecution timeMemory
487701Koosha_mvIdeal city (IOI12_city)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl #define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define Add(x,y) x=(x+y)%mod #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=1e6+99,mod=1e9; int n,t,w[N]; pair<int,int> a[N]; vector<int> g[N]; map<pair<int,int>,int> edge,mark; int ans; void Add_edge(ll u,ll v){ if(edge[mp(u,v)]) return ; g[u].pb(v); g[v].pb(u); edge[mp(u,v)]=1; edge[mp(v,u)]=1; } void dfs(ll x,ll par){ f(i,0,g[x].size()){ if(g[x][i]!=par){ dfs(g[x][i],x); w[x]+=w[g[x][i]]; } } Add(ans,1ll*w[x]*(n-w[x])%mod); } void solve(){ f(i,0,N) g[i].clear(); fiint(w,w+N,0); mark.clear(); edge.clear(); sort(a,a+n); int cnt=1; f(i,0,n){ mark[mp(a[i].F,a[i].S)]=mark[mp(a[i].F-1,a[i].S)]; if(!mark[mp(a[i].F,a[i].S)]){ mark[mp(a[i].F,a[i].S)]=cnt++; } w[mark[mp(a[i].F,a[i].S)]]++; } f(i,0,n){ if(mark[mp(a[i].F,a[i].S+1)]){ Add_edge(mark[mp(a[i].F,a[i].S)],mark[mp(a[i].F,a[i].S+1)]); } } dfs(1,0); } int DistanceSum(int N,int *X,int *Y){ n=N; f(i,0,n) a[i].F=X[i],a[i].S=Y[i]; solve(); f(i,0,n) a[i].F=Y[i],a[i].S=X[i]; solve(); return ans%mod; } /* 2,5 v = (2, 6), v = (3, 3), v = (3, 6), v = (4, 3), v = (4, 4), v = (4, 5), v = (4, 6), v = (5, 3), v = (5, 4), and v = (5, 6) 11 2 5 2 6 3 3 3 6 4 3 4 4 4 5 4 6 5 3 5 4 5 6 */

Compilation message (stderr)

city.cpp: In function 'void dfs(long long int, long long int)':
city.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   36 |  f(i,0,g[x].size()){
      |    ~~~~~~~~~~~~~~~             
city.cpp:36:2: note: in expansion of macro 'f'
   36 |  f(i,0,g[x].size()){
      |  ^
city.cpp: In function 'void solve()':
city.cpp:46:2: error: 'fiint' was not declared in this scope
   46 |  fiint(w,w+N,0);
      |  ^~~~~