답안 #734562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734562 2023-05-02T16:01:06 Z bin9638 게임 (APIO22_game) C++17
60 / 100
597 ms 5864 KB
#include <bits/stdc++.h>

#ifndef SKY
#include "game.h"
#endif // SKY

using namespace std;

#define N 100010
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back

int dp[N],n,k;
vector<int>g[N];

void init(int NNN, int KKK)
{
    n=NNN;
    k=KKK;
    memset(dp,0x3f3f,sizeof(dp));
}

void solve(int u)
{
    int val=(u<k ? u : dp[u]);
    for(auto v:g[u])
        if(dp[v]>val)
        {
            dp[v]=val;
            solve(v);
        }
}

int add_teleporter(int u, int v)
{
    g[v].pb(u);
    solve(v);
   // cout<<u<<" "<<v<<endl;
  //  for(int i=0;i<n;i++)cout<<dp[i]<<" ";cout<<endl;
    for(int i=0;i<k;i++)
        if(dp[i]<=i)
            return 1;
    return 0;
}

#ifdef SKY
int main()
{
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    init(n,k);
    int q;
    cin>>q;
    while(q--)
    {
        int u,v;
        cin>>u>>v;
        cout<<add_teleporter(u,v)<<endl;
    }
    return 0;
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3024 KB Output is correct
2 Correct 2 ms 3024 KB Output is correct
3 Correct 2 ms 3024 KB Output is correct
4 Correct 2 ms 3024 KB Output is correct
5 Correct 2 ms 3024 KB Output is correct
6 Correct 2 ms 3152 KB Output is correct
7 Correct 2 ms 3024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3024 KB Output is correct
2 Correct 2 ms 3024 KB Output is correct
3 Correct 2 ms 3024 KB Output is correct
4 Correct 2 ms 3024 KB Output is correct
5 Correct 2 ms 3024 KB Output is correct
6 Correct 2 ms 3152 KB Output is correct
7 Correct 2 ms 3024 KB Output is correct
8 Correct 2 ms 3024 KB Output is correct
9 Correct 2 ms 3024 KB Output is correct
10 Correct 3 ms 3024 KB Output is correct
11 Correct 4 ms 3024 KB Output is correct
12 Correct 4 ms 3024 KB Output is correct
13 Correct 2 ms 3024 KB Output is correct
14 Correct 2 ms 3024 KB Output is correct
15 Correct 2 ms 3024 KB Output is correct
16 Correct 2 ms 3024 KB Output is correct
17 Correct 2 ms 3024 KB Output is correct
18 Correct 2 ms 3024 KB Output is correct
19 Correct 3 ms 3024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3024 KB Output is correct
2 Correct 2 ms 3024 KB Output is correct
3 Correct 2 ms 3024 KB Output is correct
4 Correct 2 ms 3024 KB Output is correct
5 Correct 2 ms 3024 KB Output is correct
6 Correct 2 ms 3152 KB Output is correct
7 Correct 2 ms 3024 KB Output is correct
8 Correct 2 ms 3024 KB Output is correct
9 Correct 2 ms 3024 KB Output is correct
10 Correct 3 ms 3024 KB Output is correct
11 Correct 4 ms 3024 KB Output is correct
12 Correct 4 ms 3024 KB Output is correct
13 Correct 2 ms 3024 KB Output is correct
14 Correct 2 ms 3024 KB Output is correct
15 Correct 2 ms 3024 KB Output is correct
16 Correct 2 ms 3024 KB Output is correct
17 Correct 2 ms 3024 KB Output is correct
18 Correct 2 ms 3024 KB Output is correct
19 Correct 3 ms 3024 KB Output is correct
20 Correct 2 ms 3024 KB Output is correct
21 Correct 2 ms 3024 KB Output is correct
22 Correct 2 ms 3024 KB Output is correct
23 Correct 2 ms 3024 KB Output is correct
24 Correct 6 ms 3024 KB Output is correct
25 Correct 5 ms 3044 KB Output is correct
26 Correct 4 ms 3024 KB Output is correct
27 Correct 6 ms 3024 KB Output is correct
28 Correct 4 ms 3024 KB Output is correct
29 Correct 7 ms 3024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3024 KB Output is correct
2 Correct 2 ms 3024 KB Output is correct
3 Correct 2 ms 3024 KB Output is correct
4 Correct 2 ms 3024 KB Output is correct
5 Correct 2 ms 3024 KB Output is correct
6 Correct 2 ms 3152 KB Output is correct
7 Correct 2 ms 3024 KB Output is correct
8 Correct 2 ms 3024 KB Output is correct
9 Correct 2 ms 3024 KB Output is correct
10 Correct 3 ms 3024 KB Output is correct
11 Correct 4 ms 3024 KB Output is correct
12 Correct 4 ms 3024 KB Output is correct
13 Correct 2 ms 3024 KB Output is correct
14 Correct 2 ms 3024 KB Output is correct
15 Correct 2 ms 3024 KB Output is correct
16 Correct 2 ms 3024 KB Output is correct
17 Correct 2 ms 3024 KB Output is correct
18 Correct 2 ms 3024 KB Output is correct
19 Correct 3 ms 3024 KB Output is correct
20 Correct 2 ms 3024 KB Output is correct
21 Correct 2 ms 3024 KB Output is correct
22 Correct 2 ms 3024 KB Output is correct
23 Correct 2 ms 3024 KB Output is correct
24 Correct 6 ms 3024 KB Output is correct
25 Correct 5 ms 3044 KB Output is correct
26 Correct 4 ms 3024 KB Output is correct
27 Correct 6 ms 3024 KB Output is correct
28 Correct 4 ms 3024 KB Output is correct
29 Correct 7 ms 3024 KB Output is correct
30 Correct 25 ms 3544 KB Output is correct
31 Correct 13 ms 3152 KB Output is correct
32 Correct 24 ms 4580 KB Output is correct
33 Correct 17 ms 3928 KB Output is correct
34 Correct 597 ms 5304 KB Output is correct
35 Correct 222 ms 4328 KB Output is correct
36 Correct 53 ms 3908 KB Output is correct
37 Correct 59 ms 3940 KB Output is correct
38 Correct 43 ms 3924 KB Output is correct
39 Correct 47 ms 3912 KB Output is correct
40 Correct 478 ms 5328 KB Output is correct
41 Correct 118 ms 4204 KB Output is correct
42 Correct 102 ms 3988 KB Output is correct
43 Correct 57 ms 5344 KB Output is correct
44 Correct 544 ms 5304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3024 KB Output is correct
2 Correct 2 ms 3024 KB Output is correct
3 Correct 2 ms 3024 KB Output is correct
4 Correct 2 ms 3024 KB Output is correct
5 Correct 2 ms 3024 KB Output is correct
6 Correct 2 ms 3152 KB Output is correct
7 Correct 2 ms 3024 KB Output is correct
8 Correct 2 ms 3024 KB Output is correct
9 Correct 2 ms 3024 KB Output is correct
10 Correct 3 ms 3024 KB Output is correct
11 Correct 4 ms 3024 KB Output is correct
12 Correct 4 ms 3024 KB Output is correct
13 Correct 2 ms 3024 KB Output is correct
14 Correct 2 ms 3024 KB Output is correct
15 Correct 2 ms 3024 KB Output is correct
16 Correct 2 ms 3024 KB Output is correct
17 Correct 2 ms 3024 KB Output is correct
18 Correct 2 ms 3024 KB Output is correct
19 Correct 3 ms 3024 KB Output is correct
20 Correct 2 ms 3024 KB Output is correct
21 Correct 2 ms 3024 KB Output is correct
22 Correct 2 ms 3024 KB Output is correct
23 Correct 2 ms 3024 KB Output is correct
24 Correct 6 ms 3024 KB Output is correct
25 Correct 5 ms 3044 KB Output is correct
26 Correct 4 ms 3024 KB Output is correct
27 Correct 6 ms 3024 KB Output is correct
28 Correct 4 ms 3024 KB Output is correct
29 Correct 7 ms 3024 KB Output is correct
30 Correct 25 ms 3544 KB Output is correct
31 Correct 13 ms 3152 KB Output is correct
32 Correct 24 ms 4580 KB Output is correct
33 Correct 17 ms 3928 KB Output is correct
34 Correct 597 ms 5304 KB Output is correct
35 Correct 222 ms 4328 KB Output is correct
36 Correct 53 ms 3908 KB Output is correct
37 Correct 59 ms 3940 KB Output is correct
38 Correct 43 ms 3924 KB Output is correct
39 Correct 47 ms 3912 KB Output is correct
40 Correct 478 ms 5328 KB Output is correct
41 Correct 118 ms 4204 KB Output is correct
42 Correct 102 ms 3988 KB Output is correct
43 Correct 57 ms 5344 KB Output is correct
44 Correct 544 ms 5304 KB Output is correct
45 Runtime error 5 ms 5864 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -