Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
#include
using namespace std; typedef long long ll; const int maxn = 667; bool graph[maxn][maxn]; bool visited[maxn]; int match[maxn]; int n, k; bool dfs(int node) { for(int i = 0; i < n; i++) { if(graph[node][i] and !visited[i]) { visited[i] = true; if(match[i] == -1 or dfs(match[i])) { match[i] = node; return true; } } } return false; } int maximum_bipartite_matching() { memset(match, -1, sizeof match); int result = 0; for(int i = 0; i < n; i++) { memset(visited, false, sizeof visited); if(dfs(i)) { result++; } } return result; } int main() { ios_base::sync_with_stdio(false); cin >> n >> k; memset(graph, true, sizeof graph); for(int i = 0; i < k; i++) { int a, b; cin >> a >> b; a--; b--; graph[a][b] = false; } cout << maximum_bipartite_matching() << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)