Submission #719102

#TimeUsernameProblemLanguageResultExecution timeMemory
719102nguyentunglamGame (IOI14_game)C++17
42 / 100
1082 ms1316 KiB
#include<bits/stdc++.h>
using namespace std;
#include "game.h"
const int N = 1510;
bool mark[N][N], vis[N];
int n;
void initialize(int m) {
    n = m;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) mark[i][j] = 1;
    vis[0] = 1;
}

int hasEdge(int u, int v) {
    mark[u][v] = mark[v][u] = 0;
    queue<int> q;
    for(int i = 1; i < n; i++) vis[i] = 0;
    q.push(0);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for(int v = 0; v < n; v++) if (!vis[v] && mark[u][v]) {
            q.push(v); vis[v] = 1;
        }
    }
    for(int i = 0; i < n; i++) if (!vis[i]) {
        mark[u][v] = mark[v][u] = 1;
        return 1;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...