Submission #434472

# Submission time Handle Problem Language Result Execution time Memory
434472 2021-06-21T10:50:13 Z ismoilov Werewolf (IOI18_werewolf) C++14
0 / 100
297 ms 524292 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector <int>

bool vis[3003];
vector <int> g[3003];
void check(int u, int p, bool state, int l, int r, int e){
    if(u == e){
        if(state==0 || r >= p || (u <= r && u >= l)){
            vis[u] = 1;
        }
        return;
    }
    /*if(vis[u] && e != u)
        return;*/
    if(state){
        if(u < l)
            if(r >= p && u <= r)
                state = 0;
            else
                return;
    }
    else{
        if(u > r)
            return;
    }
    vis[u] = 1;
    for(auto v : g[u]){
        if(v == p)
            continue;
       // cout << v << " " << u << " " << state << "\n";
        check(v, u, state, l, r, e);
    }
}

vi check_validity(int n, vi x, vi y, vi s, vi e, vi L, vi R) {
  int m = x.size();
  for(int i = 0; i < m; i ++){
    g[x[i]].push_back(y[i]);
    g[y[i]].push_back(x[i]);
  }
  int q = s.size();

  vector <int> ans;
  for(int i = 0; i < q; i ++){
    memset(vis, 0, sizeof(vis));
    check(s[i], s[i], 1, L[i], R[i], e[i]);
    ans.push_back(vis[e[i]]);
  }
  return ans;
}

Compilation message

werewolf.cpp: In function 'void check(int, int, bool, int, int, int)':
werewolf.cpp:18:11: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   18 |         if(u < l)
      |           ^
# Verdict Execution time Memory Grader output
1 Runtime error 297 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 297 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 166 ms 19544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 297 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -