Submission #47758

# Submission time Handle Problem Language Result Execution time Memory
47758 2018-05-07T04:53:30 Z mirbek01 Bitaro’s Party (JOI18_bitaro) C++17
7 / 100
2000 ms 9420 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 2;

int n, m, q, d[N], used[N];
vector <int> g[N];

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

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

      while(q --){
            int t, 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);
            }

            set < pair <int, int> > st;
            memset(d, 0, sizeof(d));
            st.insert({d[t], t});

            int ans = -1;

            while(!st.empty()){
                  int v = st.begin()->second;
                  st.erase(st.begin());
                  if(!used[v])
                        ans = max(ans, d[v]);
                  for(int to : g[v]){
                        if(d[v] + 1 > d[to]){
                              st.erase({d[to], to});
                              d[to] = d[v] + 1;
                              st.insert({d[to], to});
                        }
                  }
            }


            cout << ans << endl;

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

Compilation message

bitaro.cpp: In function 'int main()':
bitaro.cpp:15: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:25: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 4 ms 3064 KB Output is correct
2 Correct 5 ms 3188 KB Output is correct
3 Correct 4 ms 3188 KB Output is correct
4 Correct 4 ms 3188 KB Output is correct
5 Correct 7 ms 3188 KB Output is correct
6 Correct 5 ms 3252 KB Output is correct
7 Correct 6 ms 3252 KB Output is correct
8 Correct 8 ms 3252 KB Output is correct
9 Correct 32 ms 3272 KB Output is correct
10 Correct 28 ms 3272 KB Output is correct
11 Correct 5 ms 3272 KB Output is correct
12 Correct 8 ms 3272 KB Output is correct
13 Correct 5 ms 3272 KB Output is correct
14 Correct 7 ms 3332 KB Output is correct
15 Correct 5 ms 3332 KB Output is correct
16 Correct 18 ms 3332 KB Output is correct
17 Correct 8 ms 3332 KB Output is correct
18 Correct 6 ms 3332 KB Output is correct
19 Correct 7 ms 3332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3064 KB Output is correct
2 Correct 5 ms 3188 KB Output is correct
3 Correct 4 ms 3188 KB Output is correct
4 Correct 4 ms 3188 KB Output is correct
5 Correct 7 ms 3188 KB Output is correct
6 Correct 5 ms 3252 KB Output is correct
7 Correct 6 ms 3252 KB Output is correct
8 Correct 8 ms 3252 KB Output is correct
9 Correct 32 ms 3272 KB Output is correct
10 Correct 28 ms 3272 KB Output is correct
11 Correct 5 ms 3272 KB Output is correct
12 Correct 8 ms 3272 KB Output is correct
13 Correct 5 ms 3272 KB Output is correct
14 Correct 7 ms 3332 KB Output is correct
15 Correct 5 ms 3332 KB Output is correct
16 Correct 18 ms 3332 KB Output is correct
17 Correct 8 ms 3332 KB Output is correct
18 Correct 6 ms 3332 KB Output is correct
19 Correct 7 ms 3332 KB Output is correct
20 Correct 81 ms 4700 KB Output is correct
21 Correct 63 ms 4700 KB Output is correct
22 Correct 152 ms 4700 KB Output is correct
23 Correct 57 ms 4700 KB Output is correct
24 Correct 117 ms 6760 KB Output is correct
25 Correct 101 ms 6776 KB Output is correct
26 Correct 98 ms 6776 KB Output is correct
27 Execution timed out 2074 ms 9420 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3064 KB Output is correct
2 Correct 5 ms 3188 KB Output is correct
3 Correct 4 ms 3188 KB Output is correct
4 Correct 4 ms 3188 KB Output is correct
5 Correct 7 ms 3188 KB Output is correct
6 Correct 5 ms 3252 KB Output is correct
7 Correct 6 ms 3252 KB Output is correct
8 Correct 8 ms 3252 KB Output is correct
9 Correct 32 ms 3272 KB Output is correct
10 Correct 28 ms 3272 KB Output is correct
11 Correct 5 ms 3272 KB Output is correct
12 Correct 8 ms 3272 KB Output is correct
13 Correct 5 ms 3272 KB Output is correct
14 Correct 7 ms 3332 KB Output is correct
15 Correct 5 ms 3332 KB Output is correct
16 Correct 18 ms 3332 KB Output is correct
17 Correct 8 ms 3332 KB Output is correct
18 Correct 6 ms 3332 KB Output is correct
19 Correct 7 ms 3332 KB Output is correct
20 Correct 81 ms 4700 KB Output is correct
21 Correct 63 ms 4700 KB Output is correct
22 Correct 152 ms 4700 KB Output is correct
23 Correct 57 ms 4700 KB Output is correct
24 Correct 117 ms 6760 KB Output is correct
25 Correct 101 ms 6776 KB Output is correct
26 Correct 98 ms 6776 KB Output is correct
27 Execution timed out 2074 ms 9420 KB Time limit exceeded
28 Halted 0 ms 0 KB -