Submission #968957

# Submission time Handle Problem Language Result Execution time Memory
968957 2024-04-24T10:17:06 Z duckindog Werewolf (IOI18_werewolf) C++17
15 / 100
636 ms 19800 KB
#include <bits/stdc++.h>
#include "werewolf.h"

using namespace std;

const int N = 3'000 + 10;
vector<int> ad[N];
bool f[N][2];
int mk[N];

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 m = x.size(), q = s.size();
  for (int i = 0; i < m; ++i) { 
    int u = x[i], v = y[i];
    ad[u].push_back(v);
    ad[v].push_back(u);
  }
  
  if (n <= 3000 && m <= 6000 && q <= 3000) { 
    vector<int> answer;
    for (int i = 0; i < q; ++i) { 
      vector<vector<int>> f(n, vector<int>(2));
      vector<int> mk(n);
      
      for (int j = 0; j < n; ++j) mk[j] = (j < l[i] ? 0 : j <= r[i] ? 1 : 2);

      queue<int> que;
      f[s[i]][0] = f[s[i]][mk[s[i]] == 1] = true;
      que.push(s[i]);
      while (que.size()) { 
        auto u = que.front(); que.pop();
        for (const auto& v : ad[u]) { 
          if (f[v][0] && f[v][1]) continue;
          pair<int, int> pre = {f[v][0], f[v][1]};
          if (mk[v] >= 1) f[v][0] |= f[u][0];
          if (mk[v] <= 1) f[v][1] |= (f[u][1] || mk[v] == 1);
          if (make_pair(f[v][0], f[v][1]) != pre) que.push(v);
        }
      }
      
      answer.push_back(f[e[i]][1]);
    }
    return answer;
  }
}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 424 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 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 424 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 636 ms 948 KB Output is correct
11 Correct 504 ms 1040 KB Output is correct
12 Correct 322 ms 860 KB Output is correct
13 Correct 622 ms 1056 KB Output is correct
14 Correct 553 ms 1104 KB Output is correct
15 Correct 456 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 116 ms 19800 KB Execution killed with signal 11
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 424 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 636 ms 948 KB Output is correct
11 Correct 504 ms 1040 KB Output is correct
12 Correct 322 ms 860 KB Output is correct
13 Correct 622 ms 1056 KB Output is correct
14 Correct 553 ms 1104 KB Output is correct
15 Correct 456 ms 1136 KB Output is correct
16 Runtime error 116 ms 19800 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -