Submission #1015255

# Submission time Handle Problem Language Result Execution time Memory
1015255 2024-07-06T08:02:43 Z mindiyak Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 524288 KB
#include "werewolf.h"
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

int M,Q,N;
vvi paths;
int ans_found = 0;

void dfs(int S,int E,int L, int R,int pos,int state,int can,vi visited){
  if(ans_found)return;
  if(pos == E){
    if(state == 2){ans_found=1;return;}
    if(can && state == 1){ans_found=1;return;}
  }
  if(visited[pos])return;
  visited[pos] = 1;

  // cout << pos << " " << state << " " << can << endl;

  if(state == 0){
    if(pos > R)state = 0;
    else if(pos >= L && pos <= R){state  = 1;can = 1;}
    else{return;}
  }else if(state == 1){
    if(pos >= L && pos <= R){state  = 1;can = 1;}
    else if(pos < L && can)state = 2;
    else if(pos > R)state = 0;
    else{return;}
  }else if(state == 2){
    if(pos < L)state = 2;
    else{return;}
  }
  
  for(int i:paths[pos]){
    dfs(S,E,L,R,i,state,can,visited);
  }
}

vi check_validity(int n, vi X, vi Y, vi S, vi E ,vi L, vi R) {
  N = n;M = X.size(); Q = L.size(); 
  vi ans(Q);
  paths = vvi(n,vi());
  FOR(i,0,M){
    paths[X[i]].pb(Y[i]);
    paths[Y[i]].pb(X[i]);
  }

  FOR(i,0,Q){
    ans_found = 0;
    vi visited(N,0);
    dfs(S[i],E[i],L[i],R[i],S[i],0,0,visited);
    ans[i] = ans_found;
  }
  return  ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1760 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -