Submission #47762

# Submission time Handle Problem Language Result Execution time Memory
47762 2018-05-07T05:13:29 Z mirbek01 Bitaro’s Party (JOI18_bitaro) C++17
14 / 100
2000 ms 15312 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 2;

int n, m, q, d[N], used[N], ans, vis[N], f[N], t;
vector <int> g[N], gr[N];

void dfs(int v){
      vis[v] = 1;
      for(int to : g[v]){
            if(!vis[to]){
                  dfs(to);
            }
            if(f[to]){
                  d[v] = max(d[v], d[to] + 1);
                  f[v] = 1;
            }
      }
      if(!used[v] && f[v])
            ans = max(ans, d[v]);
}

int main(){
      cin >> n >> m >> q;

      for(int i = 0; i < m; i ++){
            int u, v;
            scanf("%d %d", &u, &v);
            g[u].push_back(v);
      }

      while(q --){
            int y;
            cin >> t >> y;
            vector <int> v;
            for(int i = 1; i <= y; i ++){
                  int x;
                  scanf("%d", &x);
                  used[x] = 1;
                  v.push_back(x);
            }

            memset(d, 0, sizeof(d));
            memset(vis, 0, sizeof(vis));
            memset(f, 0, sizeof(f));
            f[t] = 1;
            ans = -1;

            for(int i = 1; i <= n; i ++){
                  if(!vis[i])
                        dfs(i);
            }

            cout << ans << endl;

            for(int i : v)
                  used[i] = 0;
      }
}

Compilation message

bitaro.cpp: In function 'int main()':
bitaro.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:40:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                   scanf("%d", &x);
                   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6264 KB Output is correct
2 Correct 9 ms 6296 KB Output is correct
3 Correct 7 ms 6344 KB Output is correct
4 Correct 52 ms 6388 KB Output is correct
5 Correct 8 ms 6464 KB Output is correct
6 Correct 8 ms 6480 KB Output is correct
7 Correct 8 ms 6480 KB Output is correct
8 Correct 8 ms 6480 KB Output is correct
9 Correct 8 ms 6480 KB Output is correct
10 Correct 9 ms 6480 KB Output is correct
11 Correct 8 ms 6480 KB Output is correct
12 Correct 8 ms 6484 KB Output is correct
13 Correct 8 ms 6508 KB Output is correct
14 Correct 8 ms 6508 KB Output is correct
15 Correct 8 ms 6508 KB Output is correct
16 Correct 9 ms 6524 KB Output is correct
17 Correct 8 ms 6524 KB Output is correct
18 Correct 10 ms 6524 KB Output is correct
19 Correct 9 ms 6524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6264 KB Output is correct
2 Correct 9 ms 6296 KB Output is correct
3 Correct 7 ms 6344 KB Output is correct
4 Correct 52 ms 6388 KB Output is correct
5 Correct 8 ms 6464 KB Output is correct
6 Correct 8 ms 6480 KB Output is correct
7 Correct 8 ms 6480 KB Output is correct
8 Correct 8 ms 6480 KB Output is correct
9 Correct 8 ms 6480 KB Output is correct
10 Correct 9 ms 6480 KB Output is correct
11 Correct 8 ms 6480 KB Output is correct
12 Correct 8 ms 6484 KB Output is correct
13 Correct 8 ms 6508 KB Output is correct
14 Correct 8 ms 6508 KB Output is correct
15 Correct 8 ms 6508 KB Output is correct
16 Correct 9 ms 6524 KB Output is correct
17 Correct 8 ms 6524 KB Output is correct
18 Correct 10 ms 6524 KB Output is correct
19 Correct 9 ms 6524 KB Output is correct
20 Correct 53 ms 7548 KB Output is correct
21 Correct 54 ms 7804 KB Output is correct
22 Correct 53 ms 7804 KB Output is correct
23 Correct 55 ms 7804 KB Output is correct
24 Correct 110 ms 9516 KB Output is correct
25 Correct 141 ms 9592 KB Output is correct
26 Correct 116 ms 9592 KB Output is correct
27 Correct 118 ms 15312 KB Output is correct
28 Correct 105 ms 15312 KB Output is correct
29 Correct 97 ms 15312 KB Output is correct
30 Correct 98 ms 15312 KB Output is correct
31 Correct 100 ms 15312 KB Output is correct
32 Correct 96 ms 15312 KB Output is correct
33 Correct 108 ms 15312 KB Output is correct
34 Correct 111 ms 15312 KB Output is correct
35 Correct 97 ms 15312 KB Output is correct
36 Correct 104 ms 15312 KB Output is correct
37 Correct 107 ms 15312 KB Output is correct
38 Correct 91 ms 15312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6264 KB Output is correct
2 Correct 9 ms 6296 KB Output is correct
3 Correct 7 ms 6344 KB Output is correct
4 Correct 52 ms 6388 KB Output is correct
5 Correct 8 ms 6464 KB Output is correct
6 Correct 8 ms 6480 KB Output is correct
7 Correct 8 ms 6480 KB Output is correct
8 Correct 8 ms 6480 KB Output is correct
9 Correct 8 ms 6480 KB Output is correct
10 Correct 9 ms 6480 KB Output is correct
11 Correct 8 ms 6480 KB Output is correct
12 Correct 8 ms 6484 KB Output is correct
13 Correct 8 ms 6508 KB Output is correct
14 Correct 8 ms 6508 KB Output is correct
15 Correct 8 ms 6508 KB Output is correct
16 Correct 9 ms 6524 KB Output is correct
17 Correct 8 ms 6524 KB Output is correct
18 Correct 10 ms 6524 KB Output is correct
19 Correct 9 ms 6524 KB Output is correct
20 Correct 53 ms 7548 KB Output is correct
21 Correct 54 ms 7804 KB Output is correct
22 Correct 53 ms 7804 KB Output is correct
23 Correct 55 ms 7804 KB Output is correct
24 Correct 110 ms 9516 KB Output is correct
25 Correct 141 ms 9592 KB Output is correct
26 Correct 116 ms 9592 KB Output is correct
27 Correct 118 ms 15312 KB Output is correct
28 Correct 105 ms 15312 KB Output is correct
29 Correct 97 ms 15312 KB Output is correct
30 Correct 98 ms 15312 KB Output is correct
31 Correct 100 ms 15312 KB Output is correct
32 Correct 96 ms 15312 KB Output is correct
33 Correct 108 ms 15312 KB Output is correct
34 Correct 111 ms 15312 KB Output is correct
35 Correct 97 ms 15312 KB Output is correct
36 Correct 104 ms 15312 KB Output is correct
37 Correct 107 ms 15312 KB Output is correct
38 Correct 91 ms 15312 KB Output is correct
39 Execution timed out 2027 ms 15312 KB Time limit exceeded
40 Halted 0 ms 0 KB -