Submission #1042978

# Submission time Handle Problem Language Result Execution time Memory
1042978 2024-08-03T16:35:34 Z thatsgonzalez Werewolf (IOI18_werewolf) C++14
0 / 100
109 ms 44320 KB
#include "werewolf.h"
#include <bits/stdc++.h>

using namespace std;

const int nmax = 1e5+100;

vector<vector<int>> g;
bitset <nmax> vis1, vis2;
bool res = false;


void dfs(int node, int endpoint, int l, int r, bool estado){

  if(!estado and node<l) {
    return;
  }
  if(estado and node>r) return;
  if(node == endpoint and estado){
    res = true; return;
  }
  else if(node == endpoint and node>=l and node<=r){
    res = true; return; 
  }

  if(!estado) vis1[node] = 1;
  else vis2[node] = 1;

  for(auto &x: g[node]){
    if(vis1[x] and !estado) continue;
    if(vis2[x] and estado) continue;

    if(x>=l and x<=r and !estado){
      dfs(x,endpoint,l,r,estado);
      dfs(x,endpoint,l,r,!estado);
    }
    else{
      dfs(x,endpoint,l,r,estado);
    }

  }

}

std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
                                std::vector<int> S, std::vector<int> E,
                                std::vector<int> L, std::vector<int> R) {
  int Q = S.size();
  int M = X.size();
  std::vector<int> ans(Q,0);

  g.resize(N);
  
  for(int i = 0; i<M; i++){

    g[X[i]].push_back(Y[i]);
    g[Y[i]].push_back(X[i]);

  }

  for(int q = 0; q<Q; q++){

    res = false;

    dfs(S[q],E[q],L[q],R[q],0);

    ans[q] = res;

    vis1.reset();
    vis2.reset();

  }


  return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 109 ms 44320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -