제출 #974035

#제출 시각아이디문제언어결과실행 시간메모리
974035Tuanlinh123게임 (APIO22_game)C++17
60 / 100
528 ms9560 KiB
// #include "grader.cpp"
#include "game.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

const ll maxn=30005, maxk=1024;
ll n, k;
vector <ll> A[maxn];
bitset <maxn> check[maxk];

void init(int N, int K)
{
    n=N, k=K;
    for (ll i=0; i<k; i++)
        for (ll j=i+1; j<k; j++)
            check[i][j]=1;
}

int add_teleporter(int u, int v) 
{
    A[u].pb(v);
    for (ll i=0; i<k; i++)
    {
        if ((!check[i][u] && u!=i) || check[i][v]) continue;
        queue <ll> q; q.push(v), check[i][v]=1;
        while (sz(q))
        {
            ll x=q.front(); q.pop();
            if (x==i) return 1;
            for (ll y:A[x])
                if (!check[i][y])
                    check[i][y]=1, q.push(y);
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...