Submission #982992

# Submission time Handle Problem Language Result Execution time Memory
982992 2024-05-15T06:37:43 Z Faisal_Saqib Game (APIO22_game) C++17
12 / 100
4000 ms 732 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=1000;
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);
    for(int sp=0;sp<k;sp++)
    {
        memset(vis,0,sizeof(vis));
        cycle=0;
        spp=sp;
        dfs(sp);
        if(cycle)
        {
            return 1;
        }
        // cout<<"-----------------------------------------------------\n";
    }    
    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 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 13 ms 344 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 13 ms 344 KB Output is correct
6 Correct 12 ms 456 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 13 ms 344 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 13 ms 344 KB Output is correct
6 Correct 12 ms 456 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 5 ms 356 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 13 ms 344 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 13 ms 344 KB Output is correct
6 Correct 12 ms 456 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 5 ms 356 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
22 Correct 39 ms 476 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1131 ms 732 KB Output is correct
25 Correct 2838 ms 716 KB Output is correct
26 Correct 1781 ms 712 KB Output is correct
27 Execution timed out 4080 ms 724 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 13 ms 344 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 13 ms 344 KB Output is correct
6 Correct 12 ms 456 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 5 ms 356 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
22 Correct 39 ms 476 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1131 ms 732 KB Output is correct
25 Correct 2838 ms 716 KB Output is correct
26 Correct 1781 ms 712 KB Output is correct
27 Execution timed out 4080 ms 724 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 13 ms 344 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 13 ms 344 KB Output is correct
6 Correct 12 ms 456 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 5 ms 356 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
22 Correct 39 ms 476 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1131 ms 732 KB Output is correct
25 Correct 2838 ms 716 KB Output is correct
26 Correct 1781 ms 712 KB Output is correct
27 Execution timed out 4080 ms 724 KB Time limit exceeded
28 Halted 0 ms 0 KB -