답안 #718400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718400 2023-04-04T01:20:43 Z lam 게임 (APIO22_game) C++17
30 / 100
4000 ms 8028 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int n,k;
typedef pair<int,int> ii;
#define ff first
#define ss second
const int maxn = 3e5 + 10;
vector <int> adj[maxn];
int l[maxn],t[maxn],cnt,num[maxn];
int scc,id[maxn];
stack<int> st;
bool dau[maxn];

void dfs(int x)
{
    st.push(x);
    l[x]=t[x]=++cnt;
    for (int i:adj[x])
        if (!dau[i])
    {
        if (t[i]==0)
        {
            dfs(i);
            l[x]=min(l[x],l[i]);
        }
        else l[x]=min(l[x],t[i]);
    }
    if (l[x]==t[x])
    {
        int temp; scc++;
        do
        {
            temp=st.top(); st.pop();
            dau[temp]=1;
            id[temp]=scc;
        }
        while (temp!=x);
    }
}

bool check()
{
    for (int i=1; i<=n; i++) l[i]=t[i]=dau[i]=id[i]=num[i]=0;
    while (!st.empty()) st.pop();
    cnt=scc=0;
    for (int i=1; i<=n; i++) if (!t[i]) dfs(i);
    for (int i=1; i<=n; i++)
        for (int j:adj[i])
            if (id[i]==id[j]) num[id[i]]++;
    for (int i=1; i<=k; i++) if (num[id[i]]>0) return 1;
    return 0;
}

void init(int N, int K) {
    n=N; k=K;
    for (int i=1; i<=n; i++) adj[i].clear();
    for (int i=2; i<=k; i++) adj[i-1].push_back(i);
}

int add_teleporter(int u, int v) {
    u++; v++;
    adj[u].push_back(v);
    return check();
}

Compilation message

game.cpp: In function 'bool check()':
game.cpp:45:52: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   45 |     for (int i=1; i<=n; i++) l[i]=t[i]=dau[i]=id[i]=num[i]=0;
      |                                               ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7376 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 5 ms 7376 KB Output is correct
4 Correct 5 ms 7320 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 5 ms 7376 KB Output is correct
7 Correct 5 ms 7376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7376 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 5 ms 7376 KB Output is correct
4 Correct 5 ms 7320 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 5 ms 7376 KB Output is correct
7 Correct 5 ms 7376 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7376 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 5 ms 7376 KB Output is correct
12 Correct 5 ms 7376 KB Output is correct
13 Correct 4 ms 7376 KB Output is correct
14 Correct 4 ms 7376 KB Output is correct
15 Correct 5 ms 7376 KB Output is correct
16 Correct 5 ms 7312 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 5 ms 7376 KB Output is correct
19 Correct 6 ms 7248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7376 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 5 ms 7376 KB Output is correct
4 Correct 5 ms 7320 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 5 ms 7376 KB Output is correct
7 Correct 5 ms 7376 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7376 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 5 ms 7376 KB Output is correct
12 Correct 5 ms 7376 KB Output is correct
13 Correct 4 ms 7376 KB Output is correct
14 Correct 4 ms 7376 KB Output is correct
15 Correct 5 ms 7376 KB Output is correct
16 Correct 5 ms 7312 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 5 ms 7376 KB Output is correct
19 Correct 6 ms 7248 KB Output is correct
20 Correct 23 ms 7408 KB Output is correct
21 Correct 6 ms 7376 KB Output is correct
22 Correct 23 ms 7412 KB Output is correct
23 Correct 26 ms 7404 KB Output is correct
24 Correct 24 ms 7376 KB Output is correct
25 Correct 141 ms 7424 KB Output is correct
26 Correct 166 ms 7544 KB Output is correct
27 Correct 133 ms 7452 KB Output is correct
28 Correct 56 ms 7440 KB Output is correct
29 Correct 131 ms 7436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7376 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 5 ms 7376 KB Output is correct
4 Correct 5 ms 7320 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 5 ms 7376 KB Output is correct
7 Correct 5 ms 7376 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7376 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 5 ms 7376 KB Output is correct
12 Correct 5 ms 7376 KB Output is correct
13 Correct 4 ms 7376 KB Output is correct
14 Correct 4 ms 7376 KB Output is correct
15 Correct 5 ms 7376 KB Output is correct
16 Correct 5 ms 7312 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 5 ms 7376 KB Output is correct
19 Correct 6 ms 7248 KB Output is correct
20 Correct 23 ms 7408 KB Output is correct
21 Correct 6 ms 7376 KB Output is correct
22 Correct 23 ms 7412 KB Output is correct
23 Correct 26 ms 7404 KB Output is correct
24 Correct 24 ms 7376 KB Output is correct
25 Correct 141 ms 7424 KB Output is correct
26 Correct 166 ms 7544 KB Output is correct
27 Correct 133 ms 7452 KB Output is correct
28 Correct 56 ms 7440 KB Output is correct
29 Correct 131 ms 7436 KB Output is correct
30 Execution timed out 4026 ms 8028 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7376 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 5 ms 7376 KB Output is correct
4 Correct 5 ms 7320 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 5 ms 7376 KB Output is correct
7 Correct 5 ms 7376 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7376 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 5 ms 7376 KB Output is correct
12 Correct 5 ms 7376 KB Output is correct
13 Correct 4 ms 7376 KB Output is correct
14 Correct 4 ms 7376 KB Output is correct
15 Correct 5 ms 7376 KB Output is correct
16 Correct 5 ms 7312 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 5 ms 7376 KB Output is correct
19 Correct 6 ms 7248 KB Output is correct
20 Correct 23 ms 7408 KB Output is correct
21 Correct 6 ms 7376 KB Output is correct
22 Correct 23 ms 7412 KB Output is correct
23 Correct 26 ms 7404 KB Output is correct
24 Correct 24 ms 7376 KB Output is correct
25 Correct 141 ms 7424 KB Output is correct
26 Correct 166 ms 7544 KB Output is correct
27 Correct 133 ms 7452 KB Output is correct
28 Correct 56 ms 7440 KB Output is correct
29 Correct 131 ms 7436 KB Output is correct
30 Execution timed out 4026 ms 8028 KB Time limit exceeded
31 Halted 0 ms 0 KB -