QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55437#1344. Rooks GameckisekiCompile Error//C++1.6kb2022-10-13 19:17:232022-10-13 19:17:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-13 19:17:25]
  • 评测
  • [2022-10-13 19:17:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

struct BipartiteMatching {
  vector<int> X[N];
  int fX[N], fY[N], n;
  bitset<N> vis;
  bool dfs(int x) {
    for (auto i : X[x]) if (not vis[i]) {
      vis[i] = true;
      if (fY[i] == -1 || dfs(fY[i])) {
        fY[fX[x] = i] = x;
        return true;
      }
    }
    return false;
  }
  void init(int n_, int m) {
    vis.reset();
    fill(X, X + (n = n_), vector<int>());
    memset(fX, -1, sizeof(int) * n);
    memset(fY, -1, sizeof(int) * m);
  }
  void add_edge(int x, int y) { X[x].push_back(y); }
  int solve() { // return how many pair matched
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      vis.reset();
      cnt += dfs(i);
    }
    return cnt;
  }
} bi;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m; cin >> n >> m;
    bi.init(n, n);
    vector<vector<int>> g(n + n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        --a, --b;
        bi.add_edge(a, b);
        g[a].push_back(b + n);
        g[b + n].push_back(a);
    }
    auto count = [&]{
        int ans = 0;
        vector<bool> vis(n + n);
        auto dfs = [&](auto self, int i) -> void {
            vis[i] = true;
            for (int j : g[i]) {
                if (not vis[j]) self(self, j);
            }
        };
        for (int i = 0; i < n + n; ++i) {
            if (vis[i]) continue;
            if (g[i].empty()) continue;
            dfs(dfs, i);
            ans++;
        }
        return ans;
    };
    cout << m - bi.solve() << ' ' << m - count() << '\n';
    return 0;
}

详细

answer.code:5:17: error: ‘N’ was not declared in this scope
    5 |   vector<int> X[N];
      |                 ^
answer.code:6:10: error: ‘N’ was not declared in this scope
    6 |   int fX[N], fY[N], n;
      |          ^
answer.code:6:17: error: ‘N’ was not declared in this scope
    6 |   int fX[N], fY[N], n;
      |                 ^
answer.code:7:10: error: ‘N’ was not declared in this scope
    7 |   bitset<N> vis;
      |          ^
answer.code:7:11: error: template argument 1 is invalid
    7 |   bitset<N> vis;
      |           ^
answer.code: In member function ‘bool BipartiteMatching::dfs(int)’:
answer.code:9:19: error: ‘X’ was not declared in this scope
    9 |     for (auto i : X[x]) if (not vis[i]) {
      |                   ^
answer.code:11:11: error: ‘fY’ was not declared in this scope
   11 |       if (fY[i] == -1 || dfs(fY[i])) {
      |           ^~
answer.code:12:12: error: ‘fX’ was not declared in this scope
   12 |         fY[fX[x] = i] = x;
      |            ^~
answer.code: In member function ‘void BipartiteMatching::init(int, int)’:
answer.code:19:9: error: request for member ‘reset’ in ‘((BipartiteMatching*)this)->BipartiteMatching::vis’, which is of non-class type ‘int’
   19 |     vis.reset();
      |         ^~~~~
answer.code:20:10: error: ‘X’ was not declared in this scope
   20 |     fill(X, X + (n = n_), vector<int>());
      |          ^
answer.code:21:12: error: ‘fX’ was not declared in this scope
   21 |     memset(fX, -1, sizeof(int) * n);
      |            ^~
answer.code:22:12: error: ‘fY’ was not declared in this scope
   22 |     memset(fY, -1, sizeof(int) * m);
      |            ^~
answer.code: In member function ‘void BipartiteMatching::add_edge(int, int)’:
answer.code:24:33: error: ‘X’ was not declared in this scope
   24 |   void add_edge(int x, int y) { X[x].push_back(y); }
      |                                 ^
answer.code: In member function ‘int BipartiteMatching::solve()’:
answer.code:28:11: error: request for member ‘reset’ in ‘((BipartiteMatching*)this)->BipartiteMatching::vis’, which is of non-class type ‘int’
   28 |       vis.reset();
      |           ^~~~~