Submission #381211

#TimeUsernameProblemLanguageResultExecution timeMemory
381211Pichon5Werewolf (IOI18_werewolf)C++17
0 / 100
4054 ms30088 KiB
#include "werewolf.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair using namespace std; vector<vi>G; vector<pair<int,int> >color;//1 es que se vuelve wolf vector<bool>vis1,vis2; void dfs1(int nodo, int L){ vis1[nodo]=true; for(auto it : G[nodo]){ if(vis1[it]==false && it>=L){ dfs1(it,L); } } } void dfs2(int nodo,int R){ vis2[nodo]=true; for(auto it : G[nodo]){ if(vis2[it]==false && it<=R){ dfs2(it,R); } } } vi check_validity(int N,vi X,vi Y,vi S,vi E,vi L,vi R) { //N number of cities //X ^ Y roads //S ^ E start and end //avoid 0,1...L-1 in human form //avoid R+1,R+2...N-1 in wolf form int Q = S.size(); vi res; int n=N; G.assign(n+1,vi()); for(int i=0;i<X.size();i++){ G[X[i]].pb(Y[i]); G[Y[i]].pb(X[i]); } for(int i=0;i<Q;i++){ int a=S[i],b=E[i]; int ok=0; if(a<=L[i]-1 or b>=R[i]+1){ res.pb(0); continue; } vis2.assign(n+1,false); vis1.assign(n+1,false); dfs1(a,L[i]);dfs2(b,R[i]); for(int l=L[i];l<=R[l];l++){ if(vis1[l]==vis2[l] && vis1[l]==1){ ok=1;break; } } res.pb(ok); } return res; } /* 6 6 3 5 1 1 2 1 3 3 4 3 0 5 2 4 2 1 2 4 2 2 2 5 4 3 4 */

Compilation message (stderr)

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:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0;i<X.size();i++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...