#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=300005;
ll n, k, a[20][maxn];
vector <ll> A[maxn], At[maxn];
bool ismid[20][maxn];
ll propagate(ll i, ll r, ll t)
{
queue <ll> q;
if (a[i][r]+t==3) return 1;
if (!a[i][r]) a[i][r]=t, q.push(r);
while (sz(q))
{
ll u=q.front(); q.pop();
for (ll v:(t==1?A[u]:At[u]))
{
if (a[i][v]+t==3) return 1;
if (!a[i][v]) a[i][v]=t, q.push(v);
}
}
return 0;
}
ll addedge(ll u, ll v)
{
A[u].pb(v), At[v].pb(u);
for (ll i=0, oku=3, okv=3; i<20 && oku==okv; i++)
{
if (a[i][u]==1) if (propagate(i, v, 1)) return 1;
if ((a[i][v]==2 || ismid[i][v]) && oku) if (propagate(i, u, 2)) return 1;
oku&=a[i][u], okv&=a[i][v];
}
return 0;
}
void init(int N, int K)
{
n=N, k=K;
function <void(ll, ll, ll)> init=[&](ll l, ll r, ll lay)
{
if (l>r) return;
ll mid=(l+r)/2; a[lay][mid]=ismid[lay][mid]=1;
init(l, mid-1, lay+1), init(mid+1, r, lay+1);
}; init(0, k-1, 0);
for (ll i=0; i+1<k; i++) addedge(i, i+1);
}
int add_teleporter(int u, int v) {return addedge(u, v);}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16728 KB |
Output is correct |
2 |
Correct |
5 ms |
22872 KB |
Output is correct |
3 |
Correct |
5 ms |
26968 KB |
Output is correct |
4 |
Correct |
4 ms |
24920 KB |
Output is correct |
5 |
Incorrect |
6 ms |
26968 KB |
Wrong Answer[1] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16728 KB |
Output is correct |
2 |
Correct |
5 ms |
22872 KB |
Output is correct |
3 |
Correct |
5 ms |
26968 KB |
Output is correct |
4 |
Correct |
4 ms |
24920 KB |
Output is correct |
5 |
Incorrect |
6 ms |
26968 KB |
Wrong Answer[1] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16728 KB |
Output is correct |
2 |
Correct |
5 ms |
22872 KB |
Output is correct |
3 |
Correct |
5 ms |
26968 KB |
Output is correct |
4 |
Correct |
4 ms |
24920 KB |
Output is correct |
5 |
Incorrect |
6 ms |
26968 KB |
Wrong Answer[1] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16728 KB |
Output is correct |
2 |
Correct |
5 ms |
22872 KB |
Output is correct |
3 |
Correct |
5 ms |
26968 KB |
Output is correct |
4 |
Correct |
4 ms |
24920 KB |
Output is correct |
5 |
Incorrect |
6 ms |
26968 KB |
Wrong Answer[1] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16728 KB |
Output is correct |
2 |
Correct |
5 ms |
22872 KB |
Output is correct |
3 |
Correct |
5 ms |
26968 KB |
Output is correct |
4 |
Correct |
4 ms |
24920 KB |
Output is correct |
5 |
Incorrect |
6 ms |
26968 KB |
Wrong Answer[1] |
6 |
Halted |
0 ms |
0 KB |
- |