제출 #960189

#제출 시각아이디문제언어결과실행 시간메모리
960189vjudge1Game (IOI14_game)C++17
0 / 100
1 ms2492 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1500;
 
int n;
bitset<N> adj[N], edge[N];
 
void initialize(int nn) {
    n = nn;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            adj[i][j] = 1;
        }
    }
}
 
int hasEdge(int u, int v) {
    if (edge[u][v]) return 1;

    adj[u][v] = adj[v][u] = 0;

    if (adj[u].count() == 1) {
        int x = 0;
        while (!adj[u][x]) x++;

        adj[u][x] = adj[x][u] = 0;
        edge[u][x] = edge[x][u] = 1;
    }

    if (adj[v].count() == 1) {
        int x = 0;
        while (!adj[v][x]) x++;
        
        adj[v][x] = adj[x][v] = 0;
        edge[v][x] = edge[x][v] = 1;
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...