Submission #744526

# Submission time Handle Problem Language Result Execution time Memory
744526 2023-05-18T16:49:03 Z amirhoseinfar1385 Game (APIO22_game) C++17
30 / 100
4000 ms 77132 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=300000+10,maxk=1000+10;
int fk=0,fn=0,f=0;
vector<int>adj[maxn],revadj[maxn];
char vis[maxn][maxk],revvis[maxn][maxk];

void dfs(int u,int v){
  if(revvis[u][v]==1){
    f=1;
  }
  vis[u][v]=1;
  for(auto x:adj[u]){
    if(vis[x][v]==0){
      dfs(x,v);
    }
  }
}

void revdfs(int u,int v){
  if(vis[u][v]==1){
    f=1;
  }
  revvis[u][v]=1;
  for(auto x:revadj[u]){
    if(revvis[x][v]==0){
      revdfs(x,v);
    }
  }
}

void con(int a,int b){
  if(a==b&&a<fk){
    f=1;
    return;
  }
  adj[a].push_back(b);
  revadj[b].push_back(a);
  for(int i=0;i<fk;i++){
    if(vis[a][i]==1&&vis[b][i]==0){
      dfs(b,i);
    }
    if(revvis[a][i]==0&&revvis[b][i]==1){
      revdfs(a,i);
    }
  }
}

void init(int n, int k) {
  for(int i=0;i<k;i++){
    vis[i][i]=revvis[i][i]=1;
  }
  fk=k;
  fn=n;
  for(int i=0;i<k-1;i++){
    con(i,i+1);
  }
}


int add_teleporter(int u, int v) {
  con(u,v);
  if(f){
    return 1;
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 10 ms 14600 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 8 ms 14484 KB Output is correct
6 Correct 8 ms 14544 KB Output is correct
7 Correct 8 ms 14524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 10 ms 14600 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 8 ms 14484 KB Output is correct
6 Correct 8 ms 14544 KB Output is correct
7 Correct 8 ms 14524 KB Output is correct
8 Correct 8 ms 14416 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14508 KB Output is correct
12 Correct 7 ms 14544 KB Output is correct
13 Correct 9 ms 14556 KB Output is correct
14 Correct 8 ms 14544 KB Output is correct
15 Correct 8 ms 14544 KB Output is correct
16 Correct 8 ms 14544 KB Output is correct
17 Correct 8 ms 14544 KB Output is correct
18 Correct 8 ms 14544 KB Output is correct
19 Correct 8 ms 14544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 10 ms 14600 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 8 ms 14484 KB Output is correct
6 Correct 8 ms 14544 KB Output is correct
7 Correct 8 ms 14524 KB Output is correct
8 Correct 8 ms 14416 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14508 KB Output is correct
12 Correct 7 ms 14544 KB Output is correct
13 Correct 9 ms 14556 KB Output is correct
14 Correct 8 ms 14544 KB Output is correct
15 Correct 8 ms 14544 KB Output is correct
16 Correct 8 ms 14544 KB Output is correct
17 Correct 8 ms 14544 KB Output is correct
18 Correct 8 ms 14544 KB Output is correct
19 Correct 8 ms 14544 KB Output is correct
20 Correct 8 ms 15336 KB Output is correct
21 Correct 9 ms 14668 KB Output is correct
22 Correct 11 ms 16336 KB Output is correct
23 Correct 10 ms 15568 KB Output is correct
24 Correct 15 ms 16464 KB Output is correct
25 Correct 14 ms 16464 KB Output is correct
26 Correct 15 ms 16424 KB Output is correct
27 Correct 18 ms 16424 KB Output is correct
28 Correct 15 ms 16336 KB Output is correct
29 Correct 17 ms 16456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 10 ms 14600 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 8 ms 14484 KB Output is correct
6 Correct 8 ms 14544 KB Output is correct
7 Correct 8 ms 14524 KB Output is correct
8 Correct 8 ms 14416 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14508 KB Output is correct
12 Correct 7 ms 14544 KB Output is correct
13 Correct 9 ms 14556 KB Output is correct
14 Correct 8 ms 14544 KB Output is correct
15 Correct 8 ms 14544 KB Output is correct
16 Correct 8 ms 14544 KB Output is correct
17 Correct 8 ms 14544 KB Output is correct
18 Correct 8 ms 14544 KB Output is correct
19 Correct 8 ms 14544 KB Output is correct
20 Correct 8 ms 15336 KB Output is correct
21 Correct 9 ms 14668 KB Output is correct
22 Correct 11 ms 16336 KB Output is correct
23 Correct 10 ms 15568 KB Output is correct
24 Correct 15 ms 16464 KB Output is correct
25 Correct 14 ms 16464 KB Output is correct
26 Correct 15 ms 16424 KB Output is correct
27 Correct 18 ms 16424 KB Output is correct
28 Correct 15 ms 16336 KB Output is correct
29 Correct 17 ms 16456 KB Output is correct
30 Correct 44 ms 24376 KB Output is correct
31 Correct 45 ms 19560 KB Output is correct
32 Correct 184 ms 75028 KB Output is correct
33 Correct 42 ms 38236 KB Output is correct
34 Correct 2689 ms 76916 KB Output is correct
35 Correct 875 ms 75828 KB Output is correct
36 Correct 166 ms 75500 KB Output is correct
37 Correct 2055 ms 75500 KB Output is correct
38 Correct 691 ms 73856 KB Output is correct
39 Correct 621 ms 74544 KB Output is correct
40 Correct 2408 ms 77100 KB Output is correct
41 Correct 679 ms 74492 KB Output is correct
42 Correct 511 ms 70876 KB Output is correct
43 Execution timed out 4034 ms 77132 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 10 ms 14600 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 8 ms 14484 KB Output is correct
6 Correct 8 ms 14544 KB Output is correct
7 Correct 8 ms 14524 KB Output is correct
8 Correct 8 ms 14416 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14508 KB Output is correct
12 Correct 7 ms 14544 KB Output is correct
13 Correct 9 ms 14556 KB Output is correct
14 Correct 8 ms 14544 KB Output is correct
15 Correct 8 ms 14544 KB Output is correct
16 Correct 8 ms 14544 KB Output is correct
17 Correct 8 ms 14544 KB Output is correct
18 Correct 8 ms 14544 KB Output is correct
19 Correct 8 ms 14544 KB Output is correct
20 Correct 8 ms 15336 KB Output is correct
21 Correct 9 ms 14668 KB Output is correct
22 Correct 11 ms 16336 KB Output is correct
23 Correct 10 ms 15568 KB Output is correct
24 Correct 15 ms 16464 KB Output is correct
25 Correct 14 ms 16464 KB Output is correct
26 Correct 15 ms 16424 KB Output is correct
27 Correct 18 ms 16424 KB Output is correct
28 Correct 15 ms 16336 KB Output is correct
29 Correct 17 ms 16456 KB Output is correct
30 Correct 44 ms 24376 KB Output is correct
31 Correct 45 ms 19560 KB Output is correct
32 Correct 184 ms 75028 KB Output is correct
33 Correct 42 ms 38236 KB Output is correct
34 Correct 2689 ms 76916 KB Output is correct
35 Correct 875 ms 75828 KB Output is correct
36 Correct 166 ms 75500 KB Output is correct
37 Correct 2055 ms 75500 KB Output is correct
38 Correct 691 ms 73856 KB Output is correct
39 Correct 621 ms 74544 KB Output is correct
40 Correct 2408 ms 77100 KB Output is correct
41 Correct 679 ms 74492 KB Output is correct
42 Correct 511 ms 70876 KB Output is correct
43 Execution timed out 4034 ms 77132 KB Time limit exceeded
44 Halted 0 ms 0 KB -