# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47750 | 2018-05-07T04:32:05 Z | TheDarkning | Bitaro’s Party (JOI18_bitaro) | C++17 | 2000 ms | 15996 KB |
/** ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀ <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋> ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟ ♔♕♖♗♘♙ ♚♛♜♝♞♟ ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙ **/ #include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <iomanip> #include <time.h> #include <map> #include <deque> #include <assert.h> #include <queue> #include <string> #include <memory.h> #include <set> #include <math.h> #define sz(s) s.size() #define pb emplace_back #define fr first #define sc second #define mk make_pair #define int long long #define all(s) s.begin(), s.end() #define ok puts("ok"); using namespace std; const int N = 2e5 + 5; const int inf = 1e9 + 7; int n, m, q, a, b, t, y, x, ans, u[N], h[N], pr[N]; vector < int > g[N]; inline void dfs( int v, int d = 0 ){ h[ v ] = d; for( int to : g[ v ] ){ if( h[ to ] < h[ v ] + 1 ){ dfs( to, d + 1 ); } } } main(){ cin >> n >> m >> q; for( int i = 1; i <= m; i++ ){ scanf("%d%d", &a, &b); if( b > a ){ swap( a, b ); } g[ a ].pb( b ); } while( q-- ){ scanf("%d%d", &t, &y ); memset( pr, 0, sizeof( pr ) ); memset( h, 0, sizeof( h ) ); for( int i = 1; i <= y; i++ ){ scanf("%d", &x); pr[ x ] = 1; } dfs( t ); for( int i = 1; i <= n; i++ ){ if( !pr[ i ] ){ ans = max( ans, h[ i ] ); } } if( ans ){ cout << ans << endl; } else{ if( pr[ t ] ){ puts("-1"); } else{ cout << ans << endl; } } ans = 0; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 2 ms | 8316 KB | Output is correct |
3 | Correct | 10 ms | 8316 KB | Output is correct |
4 | Correct | 11 ms | 8336 KB | Output is correct |
5 | Correct | 11 ms | 8336 KB | Output is correct |
6 | Correct | 11 ms | 8352 KB | Output is correct |
7 | Correct | 12 ms | 8356 KB | Output is correct |
8 | Correct | 11 ms | 8396 KB | Output is correct |
9 | Correct | 11 ms | 8396 KB | Output is correct |
10 | Correct | 11 ms | 8396 KB | Output is correct |
11 | Correct | 11 ms | 8400 KB | Output is correct |
12 | Correct | 10 ms | 8400 KB | Output is correct |
13 | Correct | 11 ms | 8400 KB | Output is correct |
14 | Correct | 11 ms | 8400 KB | Output is correct |
15 | Correct | 8 ms | 8424 KB | Output is correct |
16 | Correct | 12 ms | 8424 KB | Output is correct |
17 | Correct | 10 ms | 8428 KB | Output is correct |
18 | Correct | 10 ms | 8428 KB | Output is correct |
19 | Correct | 10 ms | 8428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 2 ms | 8316 KB | Output is correct |
3 | Correct | 10 ms | 8316 KB | Output is correct |
4 | Correct | 11 ms | 8336 KB | Output is correct |
5 | Correct | 11 ms | 8336 KB | Output is correct |
6 | Correct | 11 ms | 8352 KB | Output is correct |
7 | Correct | 12 ms | 8356 KB | Output is correct |
8 | Correct | 11 ms | 8396 KB | Output is correct |
9 | Correct | 11 ms | 8396 KB | Output is correct |
10 | Correct | 11 ms | 8396 KB | Output is correct |
11 | Correct | 11 ms | 8400 KB | Output is correct |
12 | Correct | 10 ms | 8400 KB | Output is correct |
13 | Correct | 11 ms | 8400 KB | Output is correct |
14 | Correct | 11 ms | 8400 KB | Output is correct |
15 | Correct | 8 ms | 8424 KB | Output is correct |
16 | Correct | 12 ms | 8424 KB | Output is correct |
17 | Correct | 10 ms | 8428 KB | Output is correct |
18 | Correct | 10 ms | 8428 KB | Output is correct |
19 | Correct | 10 ms | 8428 KB | Output is correct |
20 | Correct | 75 ms | 10860 KB | Output is correct |
21 | Correct | 59 ms | 10860 KB | Output is correct |
22 | Correct | 107 ms | 10988 KB | Output is correct |
23 | Correct | 60 ms | 10988 KB | Output is correct |
24 | Correct | 123 ms | 11884 KB | Output is correct |
25 | Correct | 125 ms | 11960 KB | Output is correct |
26 | Correct | 137 ms | 11960 KB | Output is correct |
27 | Correct | 123 ms | 14844 KB | Output is correct |
28 | Correct | 137 ms | 14988 KB | Output is correct |
29 | Correct | 113 ms | 15996 KB | Output is correct |
30 | Correct | 100 ms | 15996 KB | Output is correct |
31 | Correct | 103 ms | 15996 KB | Output is correct |
32 | Correct | 103 ms | 15996 KB | Output is correct |
33 | Correct | 98 ms | 15996 KB | Output is correct |
34 | Correct | 101 ms | 15996 KB | Output is correct |
35 | Correct | 108 ms | 15996 KB | Output is correct |
36 | Correct | 1403 ms | 15996 KB | Output is correct |
37 | Correct | 101 ms | 15996 KB | Output is correct |
38 | Correct | 546 ms | 15996 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 8184 KB | Output is correct |
2 | Correct | 2 ms | 8316 KB | Output is correct |
3 | Correct | 10 ms | 8316 KB | Output is correct |
4 | Correct | 11 ms | 8336 KB | Output is correct |
5 | Correct | 11 ms | 8336 KB | Output is correct |
6 | Correct | 11 ms | 8352 KB | Output is correct |
7 | Correct | 12 ms | 8356 KB | Output is correct |
8 | Correct | 11 ms | 8396 KB | Output is correct |
9 | Correct | 11 ms | 8396 KB | Output is correct |
10 | Correct | 11 ms | 8396 KB | Output is correct |
11 | Correct | 11 ms | 8400 KB | Output is correct |
12 | Correct | 10 ms | 8400 KB | Output is correct |
13 | Correct | 11 ms | 8400 KB | Output is correct |
14 | Correct | 11 ms | 8400 KB | Output is correct |
15 | Correct | 8 ms | 8424 KB | Output is correct |
16 | Correct | 12 ms | 8424 KB | Output is correct |
17 | Correct | 10 ms | 8428 KB | Output is correct |
18 | Correct | 10 ms | 8428 KB | Output is correct |
19 | Correct | 10 ms | 8428 KB | Output is correct |
20 | Correct | 75 ms | 10860 KB | Output is correct |
21 | Correct | 59 ms | 10860 KB | Output is correct |
22 | Correct | 107 ms | 10988 KB | Output is correct |
23 | Correct | 60 ms | 10988 KB | Output is correct |
24 | Correct | 123 ms | 11884 KB | Output is correct |
25 | Correct | 125 ms | 11960 KB | Output is correct |
26 | Correct | 137 ms | 11960 KB | Output is correct |
27 | Correct | 123 ms | 14844 KB | Output is correct |
28 | Correct | 137 ms | 14988 KB | Output is correct |
29 | Correct | 113 ms | 15996 KB | Output is correct |
30 | Correct | 100 ms | 15996 KB | Output is correct |
31 | Correct | 103 ms | 15996 KB | Output is correct |
32 | Correct | 103 ms | 15996 KB | Output is correct |
33 | Correct | 98 ms | 15996 KB | Output is correct |
34 | Correct | 101 ms | 15996 KB | Output is correct |
35 | Correct | 108 ms | 15996 KB | Output is correct |
36 | Correct | 1403 ms | 15996 KB | Output is correct |
37 | Correct | 101 ms | 15996 KB | Output is correct |
38 | Correct | 546 ms | 15996 KB | Output is correct |
39 | Execution timed out | 2025 ms | 15996 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |