Submission #976412

# Submission time Handle Problem Language Result Execution time Memory
976412 2024-05-06T14:35:53 Z Unforgettablepl Game (APIO22_game) C++17
60 / 100
964 ms 6816 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

vector<int> adj[30001];
vector<int> readj[30001];
int mini[30001];
int maxi[30001];
int K,N;

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

bool ans;

void dfs(int x,int val){
    if(maxi[x]>=val or x<K)return;
    maxi[x] = val;
    if(maxi[x]>=mini[x])ans=true;
    for(int&i:adj[x])dfs(i,val);
}

void redfs(int x,int val){
    if(mini[x]<=val or x<K)return;
    mini[x] = val;
    if(maxi[x]>=mini[x])ans=true;
    for(int&i:readj[x])redfs(i,val);
}

int32_t add_teleporter(int32_t u, int32_t v) {
    if(u==v)return u<K;
    if(u<K and v<K){
        return v<=u;
    }
    adj[u].emplace_back(v);
    readj[v].emplace_back(u);
    dfs(v,maxi[u]);
    redfs(u,mini[v]);
    return ans;
}

//namespace {
//
//    int32_t read_int() {
//        int32_t x;
//        if (scanf("%d", &x) != 1) {
//            fprintf(stderr, "Error while reading input\n");
//            exit(1);
//        }
//        return x;
//    }
//
//}  // namespace
//
//int32_t main() {
//    int32_t N = read_int();
//    int32_t M = read_int();
//    int32_t K = read_int();
//    std::vector<int32_t> u(M), v(M);
//    for (int32_t i = 0; i < M; ++i) {
//        u[i] = read_int();
//        v[i] = read_int();
//    }
//
//    init(N, K);
//    int32_t i;
//    for (i = 0; i < M; ++i) {
//        int32_t answer = add_teleporter(u[i], v[i]);
//        if (answer != 0 && answer != 1) {
//            i = -1;
//            break;
//        } else if (answer == 1) {
//            break;
//        }
//    }
//    printf("%d\n", i);
//    return 0;
//}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1808 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1808 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 5 ms 1828 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1780 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1808 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 5 ms 1828 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1780 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1620 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 1 ms 1624 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 1 ms 1888 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 2136 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 2136 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1808 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 5 ms 1828 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1780 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1620 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 1 ms 1624 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 1 ms 1888 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 2136 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 2136 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 2136 KB Output is correct
30 Correct 18 ms 3928 KB Output is correct
31 Correct 6 ms 3160 KB Output is correct
32 Correct 22 ms 4956 KB Output is correct
33 Correct 16 ms 4696 KB Output is correct
34 Correct 964 ms 6192 KB Output is correct
35 Correct 324 ms 5200 KB Output is correct
36 Correct 27 ms 4696 KB Output is correct
37 Correct 32 ms 4724 KB Output is correct
38 Correct 27 ms 4168 KB Output is correct
39 Correct 33 ms 4840 KB Output is correct
40 Correct 784 ms 6388 KB Output is correct
41 Correct 154 ms 5244 KB Output is correct
42 Correct 97 ms 4608 KB Output is correct
43 Correct 46 ms 6816 KB Output is correct
44 Correct 688 ms 6240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1808 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 5 ms 1828 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 1 ms 1780 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1624 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1624 KB Output is correct
17 Correct 1 ms 1624 KB Output is correct
18 Correct 1 ms 1624 KB Output is correct
19 Correct 1 ms 1620 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 1 ms 1624 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 1 ms 1888 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 2136 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 2136 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 2136 KB Output is correct
30 Correct 18 ms 3928 KB Output is correct
31 Correct 6 ms 3160 KB Output is correct
32 Correct 22 ms 4956 KB Output is correct
33 Correct 16 ms 4696 KB Output is correct
34 Correct 964 ms 6192 KB Output is correct
35 Correct 324 ms 5200 KB Output is correct
36 Correct 27 ms 4696 KB Output is correct
37 Correct 32 ms 4724 KB Output is correct
38 Correct 27 ms 4168 KB Output is correct
39 Correct 33 ms 4840 KB Output is correct
40 Correct 784 ms 6388 KB Output is correct
41 Correct 154 ms 5244 KB Output is correct
42 Correct 97 ms 4608 KB Output is correct
43 Correct 46 ms 6816 KB Output is correct
44 Correct 688 ms 6240 KB Output is correct
45 Runtime error 2 ms 3672 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -