Submission #412133

# Submission time Handle Problem Language Result Execution time Memory
412133 2021-05-26T14:33:25 Z Ahmadsm2005 Werewolf (IOI18_werewolf) C++14
0 / 100
214 ms 21004 KB
#include "werewolf.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>edges;
bool VIS[100001][2];
int Log[200001],RMQ[200001][20],MP[200001],RMQ2[200001][20];
vector<int>TEMP;
int DFS(int X,int p=-1){
MP[X]=TEMP.size(),TEMP.push_back(X);
for(int i=0;i<edges[X].size();i++){
if(edges[X][i]!=p)
DFS(edges[X][i],X);
}
}
int querymin(int L,int R){
return min(RMQ[L][Log[R-L+1]],RMQ[R-(1<<Log[R-L+1])+1][Log[R-L+1]]);
}
int querymax(int L,int R){
return max(RMQ2[L][Log[R-L+1]],RMQ2[R-(1<<Log[R-L+1])+1][Log[R-L+1]]);
}
int BS(int S,int E,int L,int R){
int Q=MP[S],QQ=MP[E];
if(Q>QQ)
swap(Q,QQ);
int LL=Q,RR=QQ,mid,BEST=LL;
while(LL<=RR){
mid=(LL+RR)/2;
if(querymax(LL,mid)<=R)
RR=mid+1,BEST=max(mid,BEST);
else
LL=mid-1;
}
if(querymin(BEST,QQ)>=L)return 1;
return 0;
}
vector<int>check_validity(int N,vector<int>X,vector<int>Y,vector<int>S,vector<int>E,vector<int>L,vector<int>R){
Log[1]=0;
vector<int>ANS;
for(int i=1;i<N;i++)
Log[i]=Log[i/2]+1;
for(int i=0;i<N;i++)
if(edges[i].size()==1){
DFS(i);
break;
}
for(int i=0;i<N;i++)
RMQ[i][0]=TEMP[i],RMQ2[i][0]=TEMP[i];
for(int l=1;l<20;l++){
for(int i=0;i<N;i++){
RMQ[i][l]=min(RMQ[i][l-1],RMQ[i+(1<<(l-1))][l-1]);
RMQ2[i][l]=max(RMQ2[i][l-1],RMQ2[i+(1<<(l-1))][l-1]);
}
}
for(int i=0;i<S.size();i++){
ANS.push_back(BS(S[i],E[i],L[i],R[i]));
}
return ANS;
}

Compilation message

werewolf.cpp: In function 'int DFS(int, int)':
werewolf.cpp:11:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | for(int i=0;i<edges[X].size();i++){
      |             ~^~~~~~~~~~~~~~~~
werewolf.cpp:15:1: warning: no return statement in function returning non-void [-Wreturn-type]
   15 | }
      | ^
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:55:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 | for(int i=0;i<S.size();i++){
      |             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 214 ms 21004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -