Submission #381184

#TimeUsernameProblemLanguageResultExecution timeMemory
381184Pichon5Werewolf (IOI18_werewolf)C++17
7 / 100
4059 ms29292 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>vis; void dfs1(int nodo, int L){ vis[nodo]=true; for(auto it : G[nodo]){ if(vis[it]==false && it>=L){ dfs1(it,L); } } } void dfs2(int nodo,int R){ vis[nodo]=true; for(auto it : G[nodo]){ if(vis[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; for(int l=L[i];l<=R[i];l++){ vis.assign(n+1,false); dfs1(l,L[i]); if(!vis[a])continue; vis.assign(n+1,false); dfs2(l,R[i]); if(vis[b]){ 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...