답안 #362734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362734 2021-02-04T09:33:17 Z mosiashvililuka 게임 (IOI14_game) C++14
0 / 100
1 ms 384 KB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,msh[1509],zm[1509],k[1509];
int fnd(int q){
	if(msh[q]==q) return q; else return msh[q]=fnd(msh[q]);
}
void mrg(int q, int w, int rr){
	q=fnd(q);w=fnd(w);
	if(q==w) return;
	if(zm[q]<zm[w]) swap(q,w);
	msh[w]=q;
	k[q]=rr;
	if(zm[q]==zm[w]) zm[q]++;
}
void initialize(int n) {
	for(i=0; i<n; i++){
		msh[i]=i;zm[i]=1;k[i]=n-1;
	}
}

int hasEdge(int qqa, int qqb) {
	c=qqa;d=qqb;
	c=fnd(c);d=fnd(d);
	if(c==d){
		return 0;
	}
    if(k[c]!=1&&k[d]!=1){
    	k[c]--;k[d]--;
    	return 0;
	}else{
		if(k[c]==1){
			mrg(c,d,k[d]-1);
			return 1;
		}
		if(k[d]==1){
			mrg(c,d,k[c]-1);
			return 1;
		}
	}
}

Compilation message

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -