mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:28:48 +00:00
1059. [ZJOI2007]矩阵游戏
https://hydro.ac/d/bzoj/record/63b5630e291ec3514f4c4113
This commit is contained in:
parent
06464b3d39
commit
f62e720b8e
58
BZOJ/1059/1059.cpp
Normal file
58
BZOJ/1059/1059.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
int n;
|
||||
|
||||
cin >> n;
|
||||
|
||||
int ans = 0;
|
||||
std::vector<int> tag(n, -1), match(n, -1);
|
||||
std::vector<std::vector<int>> g(n);
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0, x; j < n; j++) {
|
||||
cin >> x;
|
||||
|
||||
if (x) g[i].emplace_back(j);
|
||||
}
|
||||
}
|
||||
|
||||
std::function<bool(int, int)> dfs = [&](int u, int t) {
|
||||
if (tag[u] == t) return false;
|
||||
|
||||
tag[u] = t;
|
||||
|
||||
for (int v : g[u]) {
|
||||
if (match[v] == -1 || dfs(match[v], t)) {
|
||||
match[v] = u;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (dfs(i, i)) ans++;
|
||||
}
|
||||
|
||||
cout << (ans == n ? "Yes" : "No") << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/1059/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1059/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1059/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user