//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;
int n, m;
set<int>graph[N];
vector<int> adj[N];
bool mark[N];
int match_up[N];
int match_down[N];
bool dfs(int v)
{
mark[v] = true;
for (auto u : graph[v])
{
if (match_up[u] == -1 || (!mark[match_up[u]] && dfs(match_up[u]))) { // augmenting path found!
match_up[u] = v;
match_down[v] = u;
return true;
}
}
return false;
}
int solver()
{
int ans = 0;
memset(match_down, -1, sizeof match_down);
memset(match_up, -1, sizeof match_up);
while (true)
{
bool finished = true;
memset(mark, 0, sizeof mark);
for (int i = 0; i < n * 2; i++)
{
if (match_down[i] == -1 && !mark[i] && dfs(i))
{
finished = false;
ans++;
}
}
if (finished)
{
break;
}
}
return ans;
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int u, v;
cin >> u >> v;
u--;
v--;
graph[2 * u].insert(2 * v + 1);
graph[2 * v + 1].insert(2 * u);
adj[2 * u].push_back(2 * v + 1);
adj[2 * v + 1].push_back(2 * u);
}
int max_matching = solver();
for (int i = 0; i < 2 * n; i += 2)
{
for (auto u: adj[i])
{
graph[u].erase(i);
graph[i].erase(u);
}
int num = solver();
for (auto u: adj[i])
{
graph[u].insert(i);
graph[i].insert(u);
}
if (num == max_matching)
{
cout << "Mirko" << '\n';
}
else
{
cout << "Slavko" << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1152 KB |
Output is correct |
2 |
Correct |
5 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1152 KB |
Output is correct |
2 |
Correct |
5 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1152 KB |
Output is correct |
2 |
Correct |
5 ms |
1152 KB |
Output is correct |
3 |
Correct |
5 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
1280 KB |
Output is correct |
2 |
Correct |
18 ms |
1184 KB |
Output is correct |
3 |
Correct |
20 ms |
1280 KB |
Output is correct |
4 |
Correct |
19 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1083 ms |
1916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
576 ms |
1612 KB |
Output is correct |
2 |
Correct |
385 ms |
1664 KB |
Output is correct |
3 |
Correct |
314 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
245 ms |
1536 KB |
Output is correct |
2 |
Correct |
315 ms |
1500 KB |
Output is correct |
3 |
Correct |
402 ms |
1504 KB |
Output is correct |
4 |
Correct |
260 ms |
1912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1094 ms |
1664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1096 ms |
1792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
1804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |