Submission #957610

# Submission time Handle Problem Language Result Execution time Memory
957610 2024-04-04T05:32:02 Z vjudge1 Game (APIO22_game) C++17
30 / 100
4000 ms 52904 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
//#define int long long

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

const int dx[]={-1, 1, 0, 0, 0};
const int dy[]={0, 0, 1, -1, 0};
typedef long long ll;
using namespace std;
const int mx=1e6+12;
const int mod=998244353;
const bool T=1;

vector<int> g[mx];
vector<int> e[mx];
vector<int> ord;
bool used[mx];
int comp[mx];
int cnt[mx];
int n,m,k;
int timer;
bool ans;

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

void dfs(int v){
    used[v]=1;
    for(int to:g[v]){
        if(!used[to]){
            dfs(to);
        }
    }
    ord.push_back(v);
}

void dfs(int v,int c){
    used[v]=1;
    cnt[c]++;
    comp[v]=c;
    for(int to:e[v]){
        if(!used[to]){
            dfs(to, c);
        }
    }
}

int add_teleporter(int u, int v) {
    if(ans){
        return 1;
    }
    if(v==u && v<k){
        ans=1;
        return 1;
    }
    g[u].push_back(v);
    e[v].push_back(u);
    ord.clear();
    for(int i=0;i<=n;i++){
        used[i]=cnt[i]=0;
    }
    for(int i=0;i<n;i++){
        if(!used[i]){
            dfs(i);
        }
    }
    for(int i=0;i<n;i++){
        used[i]=0;
    }
    int N=0;
    reverse(ord.begin(), ord.end());
    for(int v:ord){
        if(!used[v]){
            dfs(v, ++N);
        }
    }
    for(int i=0;i<k;i++){
        if(cnt[comp[i]]>1){
            ans=1;
            return 1;
        }
    }
    return 0;
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:70:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   70 |         used[i]=cnt[i]=0;
      |                 ~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47704 KB Output is correct
2 Correct 14 ms 51800 KB Output is correct
3 Correct 12 ms 52052 KB Output is correct
4 Correct 13 ms 51800 KB Output is correct
5 Correct 13 ms 51724 KB Output is correct
6 Correct 13 ms 51800 KB Output is correct
7 Correct 12 ms 51800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47704 KB Output is correct
2 Correct 14 ms 51800 KB Output is correct
3 Correct 12 ms 52052 KB Output is correct
4 Correct 13 ms 51800 KB Output is correct
5 Correct 13 ms 51724 KB Output is correct
6 Correct 13 ms 51800 KB Output is correct
7 Correct 12 ms 51800 KB Output is correct
8 Correct 13 ms 51800 KB Output is correct
9 Correct 10 ms 47704 KB Output is correct
10 Correct 12 ms 51800 KB Output is correct
11 Correct 11 ms 51800 KB Output is correct
12 Correct 11 ms 51800 KB Output is correct
13 Correct 11 ms 51904 KB Output is correct
14 Correct 11 ms 51800 KB Output is correct
15 Correct 12 ms 51800 KB Output is correct
16 Correct 12 ms 51928 KB Output is correct
17 Correct 12 ms 51800 KB Output is correct
18 Correct 12 ms 51800 KB Output is correct
19 Correct 12 ms 51936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47704 KB Output is correct
2 Correct 14 ms 51800 KB Output is correct
3 Correct 12 ms 52052 KB Output is correct
4 Correct 13 ms 51800 KB Output is correct
5 Correct 13 ms 51724 KB Output is correct
6 Correct 13 ms 51800 KB Output is correct
7 Correct 12 ms 51800 KB Output is correct
8 Correct 13 ms 51800 KB Output is correct
9 Correct 10 ms 47704 KB Output is correct
10 Correct 12 ms 51800 KB Output is correct
11 Correct 11 ms 51800 KB Output is correct
12 Correct 11 ms 51800 KB Output is correct
13 Correct 11 ms 51904 KB Output is correct
14 Correct 11 ms 51800 KB Output is correct
15 Correct 12 ms 51800 KB Output is correct
16 Correct 12 ms 51928 KB Output is correct
17 Correct 12 ms 51800 KB Output is correct
18 Correct 12 ms 51800 KB Output is correct
19 Correct 12 ms 51936 KB Output is correct
20 Correct 18 ms 51800 KB Output is correct
21 Correct 14 ms 51800 KB Output is correct
22 Correct 19 ms 51800 KB Output is correct
23 Correct 22 ms 51800 KB Output is correct
24 Correct 24 ms 52024 KB Output is correct
25 Correct 67 ms 51984 KB Output is correct
26 Correct 71 ms 52008 KB Output is correct
27 Correct 62 ms 52080 KB Output is correct
28 Correct 38 ms 52560 KB Output is correct
29 Correct 64 ms 51800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47704 KB Output is correct
2 Correct 14 ms 51800 KB Output is correct
3 Correct 12 ms 52052 KB Output is correct
4 Correct 13 ms 51800 KB Output is correct
5 Correct 13 ms 51724 KB Output is correct
6 Correct 13 ms 51800 KB Output is correct
7 Correct 12 ms 51800 KB Output is correct
8 Correct 13 ms 51800 KB Output is correct
9 Correct 10 ms 47704 KB Output is correct
10 Correct 12 ms 51800 KB Output is correct
11 Correct 11 ms 51800 KB Output is correct
12 Correct 11 ms 51800 KB Output is correct
13 Correct 11 ms 51904 KB Output is correct
14 Correct 11 ms 51800 KB Output is correct
15 Correct 12 ms 51800 KB Output is correct
16 Correct 12 ms 51928 KB Output is correct
17 Correct 12 ms 51800 KB Output is correct
18 Correct 12 ms 51800 KB Output is correct
19 Correct 12 ms 51936 KB Output is correct
20 Correct 18 ms 51800 KB Output is correct
21 Correct 14 ms 51800 KB Output is correct
22 Correct 19 ms 51800 KB Output is correct
23 Correct 22 ms 51800 KB Output is correct
24 Correct 24 ms 52024 KB Output is correct
25 Correct 67 ms 51984 KB Output is correct
26 Correct 71 ms 52008 KB Output is correct
27 Correct 62 ms 52080 KB Output is correct
28 Correct 38 ms 52560 KB Output is correct
29 Correct 64 ms 51800 KB Output is correct
30 Execution timed out 4024 ms 52904 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 47704 KB Output is correct
2 Correct 14 ms 51800 KB Output is correct
3 Correct 12 ms 52052 KB Output is correct
4 Correct 13 ms 51800 KB Output is correct
5 Correct 13 ms 51724 KB Output is correct
6 Correct 13 ms 51800 KB Output is correct
7 Correct 12 ms 51800 KB Output is correct
8 Correct 13 ms 51800 KB Output is correct
9 Correct 10 ms 47704 KB Output is correct
10 Correct 12 ms 51800 KB Output is correct
11 Correct 11 ms 51800 KB Output is correct
12 Correct 11 ms 51800 KB Output is correct
13 Correct 11 ms 51904 KB Output is correct
14 Correct 11 ms 51800 KB Output is correct
15 Correct 12 ms 51800 KB Output is correct
16 Correct 12 ms 51928 KB Output is correct
17 Correct 12 ms 51800 KB Output is correct
18 Correct 12 ms 51800 KB Output is correct
19 Correct 12 ms 51936 KB Output is correct
20 Correct 18 ms 51800 KB Output is correct
21 Correct 14 ms 51800 KB Output is correct
22 Correct 19 ms 51800 KB Output is correct
23 Correct 22 ms 51800 KB Output is correct
24 Correct 24 ms 52024 KB Output is correct
25 Correct 67 ms 51984 KB Output is correct
26 Correct 71 ms 52008 KB Output is correct
27 Correct 62 ms 52080 KB Output is correct
28 Correct 38 ms 52560 KB Output is correct
29 Correct 64 ms 51800 KB Output is correct
30 Execution timed out 4024 ms 52904 KB Time limit exceeded
31 Halted 0 ms 0 KB -