제출 #1174277

#제출 시각아이디문제언어결과실행 시간메모리
1174277mertbbmAmusement Park (JOI17_amusement_park)C++20
컴파일 에러
0 ms0 KiB
struct DSU{
	vector<int>e;
	void init(int n){
		e=vector<int>(n,-1);
	}
	
	int get(int x){
		return e[x]<0?x:e[x]=get(e[x]);
	}
	
	bool unite(int x, int y){
		x=get(x); y=get(y);
		if(x==y) return 0;
		if(e[x]>e[y]) swap(x,y);
		e[x]+=e[y];
		e[y]=x;
		return 1;
	}
};

vector<int>adj2[10005];
int in2[10005];
int ptr2=-1;
vector<int>storage2[65];

void dfs3(int index, int par){
	in2[index]=++ptr2;
	storage2[in2[index]%60].push_back(index);
	for(auto it:adj2[index]){
		if(it==par) continue;
		dfs3(it,index);
	}
}

void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
	DSU dsu;
	dsu.init(n+5);
	for(int x=0;x<m;x++){
		if(dsu.unite(a[x],b[x])){
			adj2[a[x]].push_back(b[x]);
			adj2[b[x]].push_back(a[x]);
		}
	}
	dfs3(0,-1);
	for(int x=0;x<60;x++){
		if(val&(1LL<<x)){
			for(auto it:storage2[x]){
				MessageBoard(it,1);
				cout << it << endl;
			}
		}
		else{
			for(auto it:storage2[x]){
				MessageBoard(it,0);
				cout << it << endl;
			}
		}
	}
}
struct DSU{
	vector<int>e;
	void init(int n){
		e=vector<int>(n,-1);
	}
	
	int get(int x){
		return e[x]<0?x:e[x]=get(e[x]);
	}
	
	bool unite(int x, int y){
		x=get(x); y=get(y);
		if(x==y) return 0;
		if(e[x]>e[y]) swap(x,y);
		e[x]+=e[y];
		e[y]=x;
		return 1;
	}
};

vector<int>adj[10005];
int in[10005];
int ptr=-1;
int pp[10005];

void dfs(int index, int par){
	in[index]=++ptr;
	for(auto it:adj[index]){
		if(it==par) continue;
		dfs(it,index);
		pp[it]=index;
	}
}

int ans[60];

int cnt=0;
void f(int index){
	if(cnt>200) return;
	//cout << index << " index" << endl;
	cnt++;
	int hold=Move(index);
	ans[in[index]%60]=hold;
}

bool visited[10005];
void dfs2(int index, int par){
	//if(par!=-1) f(index);
	//cout << index << " add\n";
	for(auto it:adj[index]){
		if(it==pp[index]) continue;
		if(it==par) continue;
		//cout << index << " " << it << " hm" << endl;
		//cout << index << " " << it << " nxt" << endl;
		f(it);
		dfs2(it,index);
	}
	//cout << index << " " << pp[index] << endl;
	//cout << index << " done\n";
	if(pp[index]==-1) return;
	else if(par==-1){
		f(pp[index]);
		dfs2(pp[index],-1);
	}
	else f(par);
}

long long Ioi(int32_t n, int32_t m, int32_t a[], int32_t b[], int32_t p, int32_t v, int32_t t){
	DSU dsu;
	dsu.init(n+5);
	for(int x=0;x<m;x++){
		if(dsu.unite(a[x],b[x])){
			adj[a[x]].push_back(b[x]);
			adj[b[x]].push_back(a[x]);
			cout << a[x] << " " << b[x] << " edge\n";
		}
	}
	memset(pp,-1,sizeof(pp));
	dfs(0,-1);
	
	memset(ans,-1,sizeof(ans));
	
	ans[in[p]%60]=v;
	
	dfs2(p,-1);
	
	long long take=0;
	for(int x=0;x<60;x++){
		if(ans[x]==-1) ans[x]=0;
		take+=(1LL<<x)*ans[x];
		//cout << take << endl;
		//cout << x << " " << ans[x] << endl;
	}
	//cout << take << " take" << endl;
	return take;
	
}

컴파일 시 표준 에러 (stderr) 메시지

# 1번째 컴파일 단계

Joi.cpp:2:9: error: 'vector' does not name a type
    2 |         vector<int>e;
      |         ^~~~~~
Joi.cpp: In member function 'void DSU::init(int)':
Joi.cpp:4:17: error: 'e' was not declared in this scope
    4 |                 e=vector<int>(n,-1);
      |                 ^
Joi.cpp:4:19: error: 'vector' was not declared in this scope
    4 |                 e=vector<int>(n,-1);
      |                   ^~~~~~~~~~~
Joi.cpp: In member function 'int DSU::get(int)':
Joi.cpp:8:24: error: 'e' was not declared in this scope
    8 |                 return e[x]<0?x:e[x]=get(e[x]);
      |                        ^
Joi.cpp: In member function 'bool DSU::unite(int, int)':
Joi.cpp:14:20: error: 'e' was not declared in this scope
   14 |                 if(e[x]>e[y]) swap(x,y);
      |                    ^
Joi.cpp:14:31: error: 'swap' was not declared in this scope
   14 |                 if(e[x]>e[y]) swap(x,y);
      |                               ^~~~
Joi.cpp:15:17: error: 'e' was not declared in this scope
   15 |                 e[x]+=e[y];
      |                 ^
Joi.cpp: At global scope:
Joi.cpp:21:1: error: 'vector' does not name a type
   21 | vector<int>adj2[10005];
      | ^~~~~~
Joi.cpp:24:1: error: 'vector' does not name a type
   24 | vector<int>storage2[65];
      | ^~~~~~
Joi.cpp: In function 'void dfs3(int, int)':
Joi.cpp:28:9: error: 'storage2' was not declared in this scope
   28 |         storage2[in2[index]%60].push_back(index);
      |         ^~~~~~~~
Joi.cpp:29:21: error: 'adj2' was not declared in this scope
   29 |         for(auto it:adj2[index]){
      |                     ^~~~
Joi.cpp: At global scope:
Joi.cpp:35:6: error: variable or field 'Joi' declared void
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |      ^~~
Joi.cpp:35:10: error: 'int32_t' was not declared in this scope
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |          ^~~~~~~
Joi.cpp:1:1: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
  +++ |+#include <cstdint>
    1 | struct DSU{
Joi.cpp:35:21: error: 'int32_t' was not declared in this scope
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |                     ^~~~~~~
Joi.cpp:35:21: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
Joi.cpp:35:32: error: 'int32_t' was not declared in this scope
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |                                ^~~~~~~
Joi.cpp:35:32: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
Joi.cpp:35:45: error: 'int32_t' was not declared in this scope
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |                                             ^~~~~~~
Joi.cpp:35:45: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
Joi.cpp:35:58: error: expected primary-expression before 'long'
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |                                                          ^~~~
Joi.cpp:35:73: error: 'int32_t' was not declared in this scope
   35 | void Joi(int32_t n, int32_t m, int32_t a[], int32_t b[], long long val, int32_t t){
      |                                                                         ^~~~~~~
Joi.cpp:35:73: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?