# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
983045 |
2024-05-15T07:19:56 Z |
Faisal_Saqib |
Game (APIO22_game) |
C++17 |
|
4000 ms |
6836 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
int n,k;
const int N=3e4+10;
vector<int> adj[N];
void init(int Q, int P)
{
n=Q;
k=P;
for(int i=0;(i+1)<k;i++)
adj[i].push_back(i+1);
}
bool cycle=0;
vector<int> path;
int vis[N];
bool have[N];
int cur=1;
void dfs(int x,int p=-1)
{
path.push_back(x);
have[x]=1;
vis[x]=cur;
for(auto y:adj[x])
{
if(vis[y]==0) // Never visited in any other dfs
{
dfs(y,x);
if(cycle)
return;
}
else if(vis[y]==cur and have[y]){ // Visited in this dfs but cycle is not guranteed
vll ex={y};
while(path.back()!=y)
{
ex.pb(path.back());
path.pop_back();
}
if(path.size()==0)
{
exit(-10);
}
for(auto lp:ex)
{
if(lp<k)
{
cycle=1;
return;
}
}
while(ex.size())
{
path.pb(ex.back());
ex.pop_back();
}
}
else{// Visited in other dfs but it will not make a cycle
// bcz if it would there would be a path from there to current node but if a path existed then we would have visited this vertex in the same dfs
}
}
path.pop_back();
have[x]=0;
}
int add_teleporter(int u, int v)
{
adj[u].push_back(v);
memset(vis,0,sizeof(vis));
cur=1;
for(int sp=0;sp<k;sp++)
{
if(!vis[sp])
{
path.clear();
cycle=0;
dfs(sp);
if(cycle)
{
return 1;
}
cur++;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
2 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
2 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
2 ms |
1112 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1112 KB |
Output is correct |
23 |
Correct |
2 ms |
1112 KB |
Output is correct |
24 |
Correct |
12 ms |
1608 KB |
Output is correct |
25 |
Correct |
39 ms |
1368 KB |
Output is correct |
26 |
Correct |
46 ms |
1368 KB |
Output is correct |
27 |
Correct |
56 ms |
1624 KB |
Output is correct |
28 |
Correct |
23 ms |
1368 KB |
Output is correct |
29 |
Correct |
52 ms |
1344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
2 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
2 ms |
1112 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1112 KB |
Output is correct |
23 |
Correct |
2 ms |
1112 KB |
Output is correct |
24 |
Correct |
12 ms |
1608 KB |
Output is correct |
25 |
Correct |
39 ms |
1368 KB |
Output is correct |
26 |
Correct |
46 ms |
1368 KB |
Output is correct |
27 |
Correct |
56 ms |
1624 KB |
Output is correct |
28 |
Correct |
23 ms |
1368 KB |
Output is correct |
29 |
Correct |
52 ms |
1344 KB |
Output is correct |
30 |
Correct |
170 ms |
2232 KB |
Output is correct |
31 |
Correct |
113 ms |
1768 KB |
Output is correct |
32 |
Correct |
101 ms |
4660 KB |
Output is correct |
33 |
Correct |
61 ms |
2108 KB |
Output is correct |
34 |
Correct |
1455 ms |
6836 KB |
Output is correct |
35 |
Execution timed out |
4038 ms |
2388 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1272 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
2 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
2 ms |
1112 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1112 KB |
Output is correct |
23 |
Correct |
2 ms |
1112 KB |
Output is correct |
24 |
Correct |
12 ms |
1608 KB |
Output is correct |
25 |
Correct |
39 ms |
1368 KB |
Output is correct |
26 |
Correct |
46 ms |
1368 KB |
Output is correct |
27 |
Correct |
56 ms |
1624 KB |
Output is correct |
28 |
Correct |
23 ms |
1368 KB |
Output is correct |
29 |
Correct |
52 ms |
1344 KB |
Output is correct |
30 |
Correct |
170 ms |
2232 KB |
Output is correct |
31 |
Correct |
113 ms |
1768 KB |
Output is correct |
32 |
Correct |
101 ms |
4660 KB |
Output is correct |
33 |
Correct |
61 ms |
2108 KB |
Output is correct |
34 |
Correct |
1455 ms |
6836 KB |
Output is correct |
35 |
Execution timed out |
4038 ms |
2388 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |