제출 #1267570

#제출 시각아이디문제언어결과실행 시간메모리
1267570cmiuc게임 (IOI14_game)C++20
15 / 100
2 ms840 KiB
#include <iostream>
#include <vector>

#include "game.h"
using namespace std;
int Nn, r, dc[1505][1505], Sum[1505], k;
vector<int> nei[1505];

void initialize(int N){
	Nn = N;
	r = (N * (N + 1)) / 2;
}

void update(int u){
	if (nei[u].size() != Nn - 2)
		return;
	int v = r - Sum[u] - u;
	dc[u][v] = dc[v][u] = 1, k++;
	if (k == Nn)
		cout<<1 / 0;

	nei[u].push_back(v), Sum[u] += v;
	nei[v].push_back(u), Sum[v] += u;
	update(v);
}

int hasEdge(int u, int v){
	u++;
	v++;

	if (dc[u][v] == 1)
		return 1;

	nei[u].push_back(v), Sum[u] += v;
	nei[v].push_back(u), Sum[v] += u;

	int ans = 0;
	if (nei[u].size() == Nn - 1 or nei[v].size() == Nn - 1)
		ans = 1; // check

	update(u);
	update(v);

	return ans;
}

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

game.cpp: In function 'void update(int)':
game.cpp:20:25: warning: division by zero [-Wdiv-by-zero]
   20 |                 cout<<1 / 0;
      |                       ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...