# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982996 |
2024-05-15T06:39:44 Z |
Faisal_Saqib |
Game (APIO22_game) |
C++17 |
|
1 ms |
1112 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;
bool vis[N];
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);
}
int spp=0;
bool cycle=0;
void dfs(int x,int p=-1)
{
// cout<<x<<' '<<p<<endl;
vis[x]=1;
for(auto y:adj[x])
{
if(!vis[y])
{
dfs(y,x);
if(cycle)
{
return;
}
}
else{
if(y==spp)
{
cycle=1;
return;
}
}
}
}
int add_teleporter(int u, int v)
{
adj[u].push_back(v);
// adj[v].push_back(u);
memset(vis,0,sizeof(vis));
for(int sp=0;sp<k;sp++)
{
if(!vis[sp])
{
cycle=0;
spp=sp;
dfs(sp);
if(cycle)
{
return 1;
}
}
}
return 0;
}
// int main()
// {
// int na,ka,ma;
// cin>>na>>ka>>ma;
// init(na,ka);
// while(ma--)
// {
// int u,v;
// cin>>u>>v;
// if(add_teleporter(u,v))
// {
// cout<<"KHatam\n";
// exit(0);
// }
// }
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1112 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1112 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1112 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1112 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1112 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |