QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#182505#4896. Alice、Bob 与 DFShos_lyric#Compile Error//C++142.8kb2023-09-18 06:32:372024-07-04 02:45:12

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:45:12]
  • 评测
  • [2023-09-18 06:32:37]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N;
vector<int> C;
vector<int> deg;
vector<vector<int>> graph;
int K;
vector<int> R;


namespace brute {
// state: just determined to call dfs(stack.back().first)
map<vector<pair<int, int>>, int> cache;
int calc(const vector<pair<int, int>> &stack) {
  auto it = cache.find(stack);
  if (it != cache.end()) return it->second;
  
  set<int> app;
  for (auto ujs = stack; ; ujs.pop_back()) {
    if (ujs.empty()) {
      app.insert(0);
      goto done;
    }
    const int u = ujs.back().first;
    for (int &j = ujs.back().second; ++j < deg[u]; ) {
      auto vjs = ujs;
      vjs.emplace_back(graph[u][j], -1);
      app.insert(calc(vjs));
      if (!C[u]) {
        goto done;
      }
    }
    last = u;
  }
 done:{}
  int ret;
  for (ret = 0; app.count(ret); ++ret) {}
// cerr<<"calc "<<stack<<" = "<<ret<<endl;
  
  return cache[stack] = ret;
}
int run() {
  cache.clear();
  int ans = 0;
  for (const int r : R) {
    ans ^= calc({make_pair(r, -1)});
  }
  return ans;
}
}  // brute


int main() {
  for (; ~scanf("%d", &N); ) {
    C.resize(N);
    for (int u = 0; u < N; ++u) {
      scanf("%d", &C[u]);
    }
    deg.resize(N);
    graph.resize(N);
    for (int u = 0; u < N; ++u) {
      scanf("%d", &deg[u]);
      graph[u].resize(deg[u]);
      for (int j = 0; j < deg[u]; ++j) {
        scanf("%d", &graph[u][j]);
        --graph[u][j];
      }
    }
    scanf("%d", &K);
    R.resize(K);
    for (int k = 0; k < K; ++k) {
      scanf("%d", &R[k]);
      --R[k];
    }
    
    const int ans = brute::run();
    puts(ans ? "Alice" : "Bob");
  }
  return 0;
}

詳細信息

answer.code: In function ‘int brute::calc(const std::vector<std::pair<int, int> >&)’:
answer.code:67:5: error: ‘last’ was not declared in this scope
   67 |     last = u;
      |     ^~~~
answer.code: In function ‘int main()’:
answer.code:91:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   91 |       scanf("%d", &C[u]);
      |       ~~~~~^~~~~~~~~~~~~
answer.code:96:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   96 |       scanf("%d", &deg[u]);
      |       ~~~~~^~~~~~~~~~~~~~~
answer.code:99:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   99 |         scanf("%d", &graph[u][j]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
answer.code:103:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  103 |     scanf("%d", &K);
      |     ~~~~~^~~~~~~~~~
answer.code:106:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  106 |       scanf("%d", &R[k]);
      |       ~~~~~^~~~~~~~~~~~~