Submission #1015280

# Submission time Handle Problem Language Result Execution time Memory
1015280 2024-07-06T08:19:17 Z mindiyak Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 32024 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;

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){
    vi w(N,0),h(N,0);
    queue<int> q;
    q.push(S[i]);
    while(!q.empty()){
      int a = q.front();q.pop();
      if(h[a]||a<L[i])continue;
      h[a] = 1;
      for(int b:paths[a])q.push(b);
    }
    q = queue<int>();
    q.push(E[i]);
    while(!q.empty()){
      int a = q.front();q.pop();
      if(w[a]||a>R[i])continue;
      w[a] = 1;
      for(int b:paths[a])q.push(b);
    }
    FOR(j,0,N){
      if(ans[i])break;
      ans[i] = w[j] && h[j];
    }
  }
  return  ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 231 ms 876 KB Output is correct
11 Correct 123 ms 860 KB Output is correct
12 Correct 19 ms 856 KB Output is correct
13 Correct 231 ms 876 KB Output is correct
14 Correct 149 ms 856 KB Output is correct
15 Correct 190 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4057 ms 32024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 231 ms 876 KB Output is correct
11 Correct 123 ms 860 KB Output is correct
12 Correct 19 ms 856 KB Output is correct
13 Correct 231 ms 876 KB Output is correct
14 Correct 149 ms 856 KB Output is correct
15 Correct 190 ms 1116 KB Output is correct
16 Execution timed out 4057 ms 32024 KB Time limit exceeded
17 Halted 0 ms 0 KB -