Submission #835098

#TimeUsernameProblemLanguageResultExecution timeMemory
835098_martynasGame (IOI14_game)C++11
42 / 100
1086 ms532 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

const int mxn = 1505;

int n;
bitset<mxn> adj[mxn];

void initialize(int N) {
    n = N;
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) {
        if(i != j) adj[i][j] = 1;
    }
}

bitset<mxn> visited;
// check if it can be connected
void dfs_could(int u) {
    visited[u] = true;
    for(int v = 0; v < n; v++) if(!visited[v]) {
        if(adj[u][v]) {
            dfs_could(v);
        }
    }
}

int hasEdge(int u, int v) {
    bool resp = false;
    visited.reset();
    adj[u][v] = adj[v][u] = false;
    dfs_could(0);
    if(visited.count() != n) {
        resp = true;
        adj[u][v] = adj[v][u] = true;
    }
    return resp;
}

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:34:24: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     if(visited.count() != n) {
      |        ~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...