답안 #487686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487686 2021-11-16T12:04:07 Z Koosha_mv 이상적인 도시 (IOI12_city) C++14
컴파일 오류
0 ms 0 KB
#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=2e5+99;

int n,t,w[N];
pair<int,int> a[N];
vector<int> g[N];
map<pair<int,int>,int> edge,mark;
ll ans;

void Add_edge(int u,int 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(int x,int par){
	f(i,0,g[x].size()){
		if(g[x][i]!=par){
			dfs(g[x][i],x);
			w[x]+=w[g[x][i]];
		}
	}
	ans+=1ll*w[x]*(n-w[x]);
}
void solve(){
	f(i,0,N) g[i].clear();
	fill(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;
}

int main(){
	//int n,s[N],t[N];
	//cin>>n;
	//f(i,0,n) cin>>s[i]>>t[i];
	//cout<<DistanceSum(n,s,t);
}
/*
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

city.cpp: In function 'void dfs(int, 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()){
      |  ^
/usr/bin/ld: /tmp/ccoacM6C.o: in function `main':
city.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqvYvgG.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status