Submission #287151

#TimeUsernameProblemLanguageResultExecution timeMemory
287151infinite_iqWerewolf (IOI18_werewolf)C++14
15 / 100
663 ms71560 KiB
#include <bits/stdc++.h> using namespace std ; #define pb push_back #define C continue typedef vector < int > vi ; #include "werewolf.h" int n , m , q ; vi v [3009] ; int p [3009][3009][2] ; int get ( int node , int t , int id ) { if ( p [node][t][id] == node ) return node ; return p [node][t][id] = get ( p [node][t][id] , t , id ) ; } void merge ( int a , int b , int t , int id ) { a = get ( a , t , id ) , b = get ( b , t , id ) ; if ( a == b ) return ; p [b][t][id] = a ; } int can ( int a , int b , int t , int id ) { a = get ( a , t , id ) , b = get ( b , t , id ) ; return ( a == b ) ; } vi check_validity ( int N , vi X , vi Y, vi S, vi E , vi L , vi R ) { n = N , m = X .size () , q = S .size () ; for ( int i = 0 ; i < m ; i ++ ) { int a = X [i] , b = Y [i] ; v [a] .pb ( b ) ; v [b] .pb ( a ) ; } for ( int i = 0 ; i < q ; i ++ ) { swap ( S [i] , E [i] ) ; } for ( int i = 0 ; i < n ; i ++ ) { p [i][0][0] = i ; } for ( int i = 0 ; i < n ; i ++ ) { if ( i ) { for ( int j = 0 ; j < n ; j ++ ) { p [j][i][0] = p [j][i-1][0] ; } } for ( auto u : v [i] ) { if ( u > i ) C ; merge ( u , i , i , 0 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { p [i][n-1][1] = i ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i != n-1 ) { for ( int j = 0 ; j < n ; j ++ ) { p [j][i][1] = p [j][i+1][1] ; } } for ( auto u : v [i] ) { if ( u < i ) C ; merge ( u , i , i , 1 ) ; } } vi ans ; for ( int i = 0 ; i < q ; i ++ ) { int a = S [i] , b = E [i] , l = L [i] , r = R [i] ; for ( int node = l ; node <= r ; node ++ ) { if ( can ( a , node , r , 0 ) && can ( node , b , l , 1 ) ) { ans .pb ( 1 ) ; break ; } } if ( ans .size () != i + 1 ) { ans .pb ( 0 ) ; } } return ans ; }

Compilation message (stderr)

werewolf.cpp: In function 'vi check_validity(int, vi, vi, vi, vi, vi, vi)':
werewolf.cpp:70:35: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   70 |                 if ( ans .size () != i + 1 ) {
      |                      ~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...