Submission #577568

#TimeUsernameProblemLanguageResultExecution timeMemory
577568MazaalaiGame (IOI14_game)C++17
0 / 100
1 ms340 KiB
#include "game.h"
#include <bits/stdc++.h>
#define lb lower_bound
#define LINE "------------\n"
using namespace std;
using PII = pair <int, int>;
const int N = 1500;
// bool path[N][N];
set <int> vals[N];
int n;
void initialize(int _n) {
    n = _n;
    for (int i = 0; i < n; i++)
    for (int j = i+1; j < n; j++) {
        vals[i].insert(j);
        vals[j].insert(i);
        // path[i][j] = path[j][i] = 1;
    }
}

int hasEdge(int u, int v) {
    // path[u][v] = path[v][u] = 0;
    vals[u].erase(v); vals[v].erase(u);
    bool vis[n]; memset(vis, 0, sizeof(vis));
    queue <int> bfs;
    if (vals[u].size() > vals[v].size()) swap(u, v);
    bfs.push(u); vis[u] = 1;
    int reach = 0;
    while(!bfs.empty()) {
        reach++;
        int x = bfs.front(); bfs.pop();
        // for (int i = 0; i < n; i++) {
        //     if (path[x][i] && !vis[i]) {
        //         bfs.push(i); vis[i] = 1;
        //     }
        // }
        for (auto el : vals[x]) {
            if (!vis[el]) {
                bfs.push(el); vis[el] = 1;
            }
        }
    }
    // if (reach != n) path[u][v] = path[v][u] = 1;
    if (reach != n) vals[u].insert(v); vals[v].insert(u);
    return reach != n;
}

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:44:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   44 |     if (reach != n) vals[u].insert(v); vals[v].insert(u);
      |     ^~
game.cpp:44:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   44 |     if (reach != n) vals[u].insert(v); vals[v].insert(u);
      |                                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...