//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#include <fstream>
using namespace std;
const int N = 10000 + 5;
vector <int> adj[N];
bool mark[N];
int n, m;
int match_down[N];
int match_up[N];
bool dfs(int v)
{
mark[v] = true;
for (auto u : adj[v])
{
if (!match_up[u] || (!mark[match_up[u]] && dfs(match_up[u])))
{
match_up[u] = v;
match_down[v] = u;
return true;
}
}
return false;
}
void solver()
{
bool finished = true;
int max_matching = 0;
while (finished)
{
memset(mark, 0, sizeof mark);
finished = false;
for (int i = 1; i <= n; i++)
{
if (!match_down[i] && !mark[i] && dfs(i))
{
finished = true;
max_matching++;
}
}
}
}
int main()
{
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int u, v;
cin >> u >> v;
adj[u].push_back(v);
}
solver();
for (int i = 1; i <= n; i++)
{
int u = match_down[i];
if (!u)
{
cout << "Mirko" << endl;
}
else
{
memset(mark, 0, sizeof mark);
bool finished = false;
match_up[u] = 0;
for (int j = 1; j <= n; j++)
{
if (j != i && !mark[j] && !match_down[j] && dfs(j))
{
finished = true;
}
}
if (finished)
{
match_down[i] = 0;
cout << "Mirko" << endl;
}
else
{
match_up[u] = i;
cout << "Slavko" << endl;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
640 KB |
Output is correct |
2 |
Correct |
7 ms |
640 KB |
Output is correct |
3 |
Correct |
9 ms |
640 KB |
Output is correct |
4 |
Correct |
8 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
768 KB |
Output is correct |
2 |
Correct |
273 ms |
768 KB |
Output is correct |
3 |
Correct |
240 ms |
908 KB |
Output is correct |
4 |
Correct |
262 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
640 KB |
Output is correct |
2 |
Correct |
10 ms |
640 KB |
Output is correct |
3 |
Correct |
9 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
640 KB |
Output is correct |
2 |
Correct |
23 ms |
640 KB |
Output is correct |
3 |
Correct |
9 ms |
640 KB |
Output is correct |
4 |
Correct |
9 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
640 KB |
Output is correct |
2 |
Correct |
175 ms |
1028 KB |
Output is correct |
3 |
Correct |
63 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
688 KB |
Output is correct |
2 |
Correct |
104 ms |
640 KB |
Output is correct |
3 |
Correct |
57 ms |
640 KB |
Output is correct |
4 |
Correct |
11 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
640 KB |
Output is correct |
2 |
Correct |
67 ms |
640 KB |
Output is correct |
3 |
Correct |
97 ms |
760 KB |
Output is correct |
4 |
Correct |
30 ms |
640 KB |
Output is correct |