Submission #710332

# Submission time Handle Problem Language Result Execution time Memory
710332 2023-03-15T07:25:41 Z Astrayt Game (APIO22_game) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005

int N, K, good = 0, t = 1, low[maxn];
vector<int> adj[maxn], rev[maxn];

void init(int n, int k){
    N = n, K = k;
    for(int i = 0; i < k - 1; ++i) adj[i].pb(i + 1), rev[i + 1].pb(i);
    for(int i = 0; i < n; ++i) low[i] = i;
}

int add_teleporter(int u, int v){
    if(u == v){
        if(u < K) return 1;
        else return 0;
    }
    bool ok = 1;
    adj[u].pb(v);
    adj[v].pb(u);
    low[u] = min(low[v], low[u]);
    queue<int> bfs; bfs.push(u);
    while(bfs.size()){
        int u = bfs.front(); bfs.pop();
        for(auto v:adj[u]){
            if(low[v] > low[u]) {
                low[v] = low[u];
                bfs.push(v);
            }
        }
    }
    if(u < K && low[u] < u) return 1;
    return 0;
}

int main(){
    int n, m, k; cin >> n >> m >> k;
    init(n, k);
    bool ok = 1;
    for(int i = 0; i < m; ++i){
        int u, v; cin >> u >> v;
        if(add_teleporter(u, v)) {
            cout << i << '\n';
            ok = 0;
            break;
        }
    }
    if(ok) cout << m << '\n';
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:21:10: warning: unused variable 'ok' [-Wunused-variable]
   21 |     bool ok = 1;
      |          ^~
/usr/bin/ld: /tmp/cc9Uk3U2.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccHJwK45.o:game.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status