Submission #690492

# Submission time Handle Problem Language Result Execution time Memory
690492 2023-01-30T08:30:14 Z zeroesandones Werewolf (IOI18_werewolf) C++17
15 / 100
261 ms 29640 KB
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;

using ll = long long;
using vi = vector<ll>;

#define pb push_back

const int mxN = 3005;
vi adj[mxN];
bool vis1[mxN];
bool vis2[mxN];

void dfs1(int x, int l) {
  vis1[x] = true;
  for(auto y : adj[x]) {
    if(!vis1[y] && y >= l) {
      dfs1(y, l);
    }
  }
}

void dfs2(int x, int r) {
  vis2[x] = true;
  for(auto y : adj[x] ){
    if(!vis2[y] && y <= r) {
      dfs2(y, r);
    }
  }
}

vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R) {
  int Q = S.size();
  vector<int> A(Q);
  for(int i = 0; i < (int) X.size(); ++i) {
    adj[X[i]].pb(Y[i]);
    adj[Y[i]].pb(X[i]);
  }

  for(int i = 0; i < Q; ++i) {
    memset(vis1, false, sizeof(vis1));
    memset(vis2, false, sizeof(vis2));
    dfs1(S[i], L[i]);
    dfs2(E[i], R[i]);
    bool pos = false;
    for(int j = L[i]; j <= R[i]; ++j) {
      if(vis1[j] && vis2[j]) {
        pos = true;
        break;
      }
    }
    A[i] = (pos ? 1 : 0);
  }

  return A;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 222 ms 748 KB Output is correct
11 Correct 130 ms 724 KB Output is correct
12 Correct 22 ms 780 KB Output is correct
13 Correct 261 ms 752 KB Output is correct
14 Correct 176 ms 724 KB Output is correct
15 Correct 248 ms 944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 140 ms 29640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 222 ms 748 KB Output is correct
11 Correct 130 ms 724 KB Output is correct
12 Correct 22 ms 780 KB Output is correct
13 Correct 261 ms 752 KB Output is correct
14 Correct 176 ms 724 KB Output is correct
15 Correct 248 ms 944 KB Output is correct
16 Runtime error 140 ms 29640 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -