Submission #47750

#TimeUsernameProblemLanguageResultExecution timeMemory
47750TheDarkningBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2025 ms15996 KiB
/** ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀ <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋> ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟ ♔♕♖♗♘♙ ♚♛♜♝♞♟ ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙ **/ #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 (stderr)

bitaro.cpp:51:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bitaro.cpp: In function 'int main()':
bitaro.cpp:54:29: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%d%d", &a, &b);
                       ~~    ^
bitaro.cpp:54:29: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
bitaro.cpp:61:30: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%d%d", &t, &y );
                       ~~     ^
bitaro.cpp:61:30: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
bitaro.cpp:65:27: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
             scanf("%d", &x);
                         ~~^
bitaro.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~
bitaro.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &t, &y );
         ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:65:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...