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
#include
using namespace std; const int maxn = 150; int graph[maxn][maxn]; bool visited[maxn]; int match[maxn]; int n; bool dfs(int node) { for(int i = 0; i < maxn; i++) { if(graph[node][i] == 1 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) == true) { result++; } } return result; } int main() { int m; cin >> n >> m; memset(graph, 0, sizeof graph); for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; graph[a][b] = 1; } cout << maximum_bipartite_matching() << endl; return 0; } /* 10 9 1 6 1 9 1 10 2 6 2 7 3 7 4 8 4 9 5 10 */
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)