답안 #652953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
652953 2022-10-25T09:30:53 Z aryan12 게임 (APIO22_game) C++17
0 / 100
4000 ms 7376 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 5;
vector<int> g[N];
int max_n, max_k;
int vis[N];
int cnt = 0;

void init(int n, int k) 
{
    max_n = n, max_k = k;
    for(int i = 0; i <= k - 2; i++)
    {
        g[i].push_back(i + 1);
    }
}

bool dfsCycle(int node)
{
    vis[node] = 1;
    cnt += (node <= max_k - 1);
    for(int to: g[node])
    {
        if(vis[to] == 1)
        {
            if(cnt != 0) return true;
            continue;
        }
        if(dfsCycle(to)) return true;
    }
    vis[node] = 2;
    cnt -= (node <= max_k - 1);
    return false;
}

int add_teleporter(int u, int v) 
{
    cnt = 0;
    g[u].push_back(v);
    for(int i = 0; i <= max_n; i++)
    {
        vis[i] = 0;
    }
    for(int i = 0; i <= max_n; i++)
    {
        if(vis[i] == 0)
        {
            if(dfsCycle(i))
            {
                return 1;
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7376 KB Output is correct
3 Execution timed out 4048 ms 7248 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7376 KB Output is correct
3 Execution timed out 4048 ms 7248 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7376 KB Output is correct
3 Execution timed out 4048 ms 7248 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7376 KB Output is correct
3 Execution timed out 4048 ms 7248 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7376 KB Output is correct
3 Execution timed out 4048 ms 7248 KB Time limit exceeded
4 Halted 0 ms 0 KB -