Submission #710168

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

int N, K;
vector<int> adj[maxn];

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

int add_teleporter(int u, int v){
    adj[u].pb(v);
    vector<bool> vis(N + 5, 0);
    queue<int> bfs;
    bfs.push(0), vis[0] = 1;
    while(bfs.size()){
        int u = bfs.front(); bfs.pop();
        for(auto v:adj[u]){
            if(vis[v]){
                if(v < K) return 1;
                continue;
            }
            bfs.push(v);
            vis[v] = 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;
        int r = add_teleporter(u, v);
        if(r) {
            cout << i << '\n';
            ok = 0;
            break;
        }
    }
    if(ok) cout << m << '\n';
}

Compilation message

/usr/bin/ld: /tmp/ccPl5zCb.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccmzWbx9.o:game.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status