답안 #1097850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097850 2024-10-08T11:02:02 Z jerzyk 게임 (APIO22_game) C++17
12 / 100
19 ms 48732 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 1000 * 1000 + 7;
int n, q;
vector<int> ed[N], red[N];
int p[N], k[N], cnt[N];
bool answer;

bool Chk(int a, int b, int r)
{
    if(r == 0) return false;
    return !(((1<<r) & a) ^ ((1<<r) & b));
}

void Upd(int v)
{
    if(p[v] > k[v] || (v >= q && p[v] >= k[v])) answer = true;
    //cerr << "U: " << v << " " << p[v] << " " << k[v] << " " << answer << "\n";
    if(answer) return;

    if(!Chk(p[v], k[v], cnt[v])) return;
    while(Chk(p[v], k[v], cnt[v])) --cnt[v];
    for(int i = 0; i < (int)ed[v].size(); ++i)
        if(p[ed[v][i]] < p[v])
        {
            p[ed[v][i]] = p[v];
            Upd(ed[v][i]);
        }
    for(int i = 0; i < (int)red[v].size(); ++i)
        if(k[red[v][i]] > k[v])
        {
            k[red[v][i]] = k[v];
            Upd(red[v][i]);
        }
}

void init(int _n, int _k)
{
    n = _n; q = _k;
    for(int i = 0; i < q; ++i)
    {
        p[i] = i + 1; k[i] = i + 1;
    }
    for(int i = q; i < n; ++i)
    {
        p[i] = 0;
        k[i] = q + 1;
        cnt[i] = 20;
    }
    for(int i = 0; i < n; ++i)
        while(Chk(p[i], k[i], cnt[i]))
            --cnt[i];
}

int add_teleporter(int u, int v)
{
    if(u == v) return 1;
    //cerr << "EDGE: " << u << " " << v << "\n";
    ed[u].pb(v); red[v].pb(u);
    if(p[v] < p[u])
    {
        p[v] = p[u];
        Upd(v);
    }
    if(k[u] > k[v])
    {
        k[u] = k[v];
        Upd(u);
    }
    if(answer)
        return 1;
    return 0;    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 48728 KB Output is correct
2 Correct 13 ms 48472 KB Output is correct
3 Correct 10 ms 48728 KB Output is correct
4 Correct 10 ms 48728 KB Output is correct
5 Correct 12 ms 48728 KB Output is correct
6 Correct 12 ms 48728 KB Output is correct
7 Correct 11 ms 48728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 48728 KB Output is correct
2 Correct 13 ms 48472 KB Output is correct
3 Correct 10 ms 48728 KB Output is correct
4 Correct 10 ms 48728 KB Output is correct
5 Correct 12 ms 48728 KB Output is correct
6 Correct 12 ms 48728 KB Output is correct
7 Correct 11 ms 48728 KB Output is correct
8 Correct 12 ms 48472 KB Output is correct
9 Correct 11 ms 48588 KB Output is correct
10 Correct 13 ms 48728 KB Output is correct
11 Correct 14 ms 48728 KB Output is correct
12 Correct 13 ms 48728 KB Output is correct
13 Correct 15 ms 48728 KB Output is correct
14 Correct 19 ms 48564 KB Output is correct
15 Correct 16 ms 48728 KB Output is correct
16 Correct 15 ms 48728 KB Output is correct
17 Correct 13 ms 48596 KB Output is correct
18 Correct 15 ms 48728 KB Output is correct
19 Correct 15 ms 48728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 48728 KB Output is correct
2 Correct 13 ms 48472 KB Output is correct
3 Correct 10 ms 48728 KB Output is correct
4 Correct 10 ms 48728 KB Output is correct
5 Correct 12 ms 48728 KB Output is correct
6 Correct 12 ms 48728 KB Output is correct
7 Correct 11 ms 48728 KB Output is correct
8 Correct 12 ms 48472 KB Output is correct
9 Correct 11 ms 48588 KB Output is correct
10 Correct 13 ms 48728 KB Output is correct
11 Correct 14 ms 48728 KB Output is correct
12 Correct 13 ms 48728 KB Output is correct
13 Correct 15 ms 48728 KB Output is correct
14 Correct 19 ms 48564 KB Output is correct
15 Correct 16 ms 48728 KB Output is correct
16 Correct 15 ms 48728 KB Output is correct
17 Correct 13 ms 48596 KB Output is correct
18 Correct 15 ms 48728 KB Output is correct
19 Correct 15 ms 48728 KB Output is correct
20 Correct 14 ms 48728 KB Output is correct
21 Correct 14 ms 48728 KB Output is correct
22 Correct 14 ms 48728 KB Output is correct
23 Incorrect 14 ms 48732 KB Wrong Answer[1]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 48728 KB Output is correct
2 Correct 13 ms 48472 KB Output is correct
3 Correct 10 ms 48728 KB Output is correct
4 Correct 10 ms 48728 KB Output is correct
5 Correct 12 ms 48728 KB Output is correct
6 Correct 12 ms 48728 KB Output is correct
7 Correct 11 ms 48728 KB Output is correct
8 Correct 12 ms 48472 KB Output is correct
9 Correct 11 ms 48588 KB Output is correct
10 Correct 13 ms 48728 KB Output is correct
11 Correct 14 ms 48728 KB Output is correct
12 Correct 13 ms 48728 KB Output is correct
13 Correct 15 ms 48728 KB Output is correct
14 Correct 19 ms 48564 KB Output is correct
15 Correct 16 ms 48728 KB Output is correct
16 Correct 15 ms 48728 KB Output is correct
17 Correct 13 ms 48596 KB Output is correct
18 Correct 15 ms 48728 KB Output is correct
19 Correct 15 ms 48728 KB Output is correct
20 Correct 14 ms 48728 KB Output is correct
21 Correct 14 ms 48728 KB Output is correct
22 Correct 14 ms 48728 KB Output is correct
23 Incorrect 14 ms 48732 KB Wrong Answer[1]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 48728 KB Output is correct
2 Correct 13 ms 48472 KB Output is correct
3 Correct 10 ms 48728 KB Output is correct
4 Correct 10 ms 48728 KB Output is correct
5 Correct 12 ms 48728 KB Output is correct
6 Correct 12 ms 48728 KB Output is correct
7 Correct 11 ms 48728 KB Output is correct
8 Correct 12 ms 48472 KB Output is correct
9 Correct 11 ms 48588 KB Output is correct
10 Correct 13 ms 48728 KB Output is correct
11 Correct 14 ms 48728 KB Output is correct
12 Correct 13 ms 48728 KB Output is correct
13 Correct 15 ms 48728 KB Output is correct
14 Correct 19 ms 48564 KB Output is correct
15 Correct 16 ms 48728 KB Output is correct
16 Correct 15 ms 48728 KB Output is correct
17 Correct 13 ms 48596 KB Output is correct
18 Correct 15 ms 48728 KB Output is correct
19 Correct 15 ms 48728 KB Output is correct
20 Correct 14 ms 48728 KB Output is correct
21 Correct 14 ms 48728 KB Output is correct
22 Correct 14 ms 48728 KB Output is correct
23 Incorrect 14 ms 48732 KB Wrong Answer[1]
24 Halted 0 ms 0 KB -