답안 #982993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982993 2024-05-15T06:38:43 Z Faisal_Saqib 게임 (APIO22_game) C++17
12 / 100
4000 ms 1452 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);
    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);
//         }
//     }

// }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 23 ms 1112 KB Output is correct
4 Correct 4 ms 1364 KB Output is correct
5 Correct 21 ms 1112 KB Output is correct
6 Correct 21 ms 1168 KB Output is correct
7 Correct 23 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 23 ms 1112 KB Output is correct
4 Correct 4 ms 1364 KB Output is correct
5 Correct 21 ms 1112 KB Output is correct
6 Correct 21 ms 1168 KB Output is correct
7 Correct 23 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 4 ms 1112 KB Output is correct
15 Correct 4 ms 1112 KB Output is correct
16 Correct 2 ms 1112 KB Output is correct
17 Correct 9 ms 1112 KB Output is correct
18 Correct 4 ms 1112 KB Output is correct
19 Correct 5 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 23 ms 1112 KB Output is correct
4 Correct 4 ms 1364 KB Output is correct
5 Correct 21 ms 1112 KB Output is correct
6 Correct 21 ms 1168 KB Output is correct
7 Correct 23 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 4 ms 1112 KB Output is correct
15 Correct 4 ms 1112 KB Output is correct
16 Correct 2 ms 1112 KB Output is correct
17 Correct 9 ms 1112 KB Output is correct
18 Correct 4 ms 1112 KB Output is correct
19 Correct 5 ms 1112 KB Output is correct
20 Correct 5 ms 1112 KB Output is correct
21 Correct 10 ms 1112 KB Output is correct
22 Correct 64 ms 1440 KB Output is correct
23 Correct 5 ms 1112 KB Output is correct
24 Correct 1263 ms 1204 KB Output is correct
25 Correct 3285 ms 1452 KB Output is correct
26 Correct 2017 ms 1200 KB Output is correct
27 Execution timed out 4016 ms 1444 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 23 ms 1112 KB Output is correct
4 Correct 4 ms 1364 KB Output is correct
5 Correct 21 ms 1112 KB Output is correct
6 Correct 21 ms 1168 KB Output is correct
7 Correct 23 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 4 ms 1112 KB Output is correct
15 Correct 4 ms 1112 KB Output is correct
16 Correct 2 ms 1112 KB Output is correct
17 Correct 9 ms 1112 KB Output is correct
18 Correct 4 ms 1112 KB Output is correct
19 Correct 5 ms 1112 KB Output is correct
20 Correct 5 ms 1112 KB Output is correct
21 Correct 10 ms 1112 KB Output is correct
22 Correct 64 ms 1440 KB Output is correct
23 Correct 5 ms 1112 KB Output is correct
24 Correct 1263 ms 1204 KB Output is correct
25 Correct 3285 ms 1452 KB Output is correct
26 Correct 2017 ms 1200 KB Output is correct
27 Execution timed out 4016 ms 1444 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 23 ms 1112 KB Output is correct
4 Correct 4 ms 1364 KB Output is correct
5 Correct 21 ms 1112 KB Output is correct
6 Correct 21 ms 1168 KB Output is correct
7 Correct 23 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 4 ms 1112 KB Output is correct
15 Correct 4 ms 1112 KB Output is correct
16 Correct 2 ms 1112 KB Output is correct
17 Correct 9 ms 1112 KB Output is correct
18 Correct 4 ms 1112 KB Output is correct
19 Correct 5 ms 1112 KB Output is correct
20 Correct 5 ms 1112 KB Output is correct
21 Correct 10 ms 1112 KB Output is correct
22 Correct 64 ms 1440 KB Output is correct
23 Correct 5 ms 1112 KB Output is correct
24 Correct 1263 ms 1204 KB Output is correct
25 Correct 3285 ms 1452 KB Output is correct
26 Correct 2017 ms 1200 KB Output is correct
27 Execution timed out 4016 ms 1444 KB Time limit exceeded
28 Halted 0 ms 0 KB -