제출 #746174

#제출 시각아이디문제언어결과실행 시간메모리
746174mnbvcxz123게임 (IOI14_game)C++17
컴파일 에러
0 ms0 KiB
int n;
int g[1505][1505];

struct DSU{
	int p[1505];
	void init(){memset(p,-1,sizeof(p));}
	int find(int x){
		if(p[x]<0)return x;
		return p[x]=find(p[x]);
	}
	void unite(int a, int b){
		a=find(a);
		b=find(b);
		if(a==b)return;
		p[a]+=p[b];
		p[b]=a;
	}
	int get(int x){return -p[find(x)];}
}dsu;

void initialize(int N){
	n=N;
	dsu.init();
}

int has_Edge(int a, int b){
	a=dsu.find(a);
	b=dsu.find(b);
	++g[a][b],++g[b][a];
	if(g[a][b]==dsu.get(a)*dsu.get(b)){
		dsu.unite(a,b);
		for(int i=0;i<n;++i){
			g[a][i]+=g[b][i];
			g[i][a]+=g[i][b];
		}
		return 1;
	}
	return 0;
}	

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

game.cpp: In member function 'void DSU::init()':
game.cpp:6:14: error: 'memset' was not declared in this scope
    6 |  void init(){memset(p,-1,sizeof(p));}
      |              ^~~~~~
game.cpp:1:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
  +++ |+#include <cstring>
    1 | int n;