이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |