This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +100500
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e9)
#define el '\n'
#define pii pair <int, int>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
int mk[N], mrk[N], i, x, y, n, m;
vector <int> g[N];
int try_kuhn(int v)
{
if (mrk[v]) return 0;
mrk[v] = 1;
for (auto u : g[v])
if (mk[u] == -1 || try_kuhn(mk[u]))
{
mk[u] = v;
return 1;
}
return 0;
}
int dfs(int v)
{
if (mrk[v]) return 0;
mrk[v] = 1;
for (auto u : g[v])
if (mk[u] == -1 || dfs(mk[u]))
return 1;
return 0;
}
int main()
{
srand(time(0));
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
// in("input.txt");
// out("output.txt");
cin >> n >> m;
for (i = 1; i <= m; i++)
{
cin >> x >> y;
y += n;
g[x].pb(y);
g[y].pb(x);
}
for (i = 1; i <= n * 2; i++) mk[i] = -1;
for (i = 1; i <= n; i++)
{
for (int j = 1; j <= n * 2; j++) mrk[j] = 0;
try_kuhn(i);
}
for (i = n + 1; i <= n + n; i++)
if (mk[i] != -1)
mk[mk[i]] = i;
for (i = 1; i <= n; i++)
if (mk[i] == -1)
cout << "Mirko" << el;
else
{
for (int j = 1; j <= n * 2; j++) mrk[j] = 0;
bool can = dfs(mk[i]);
cout << ((!can) ? "Slavko" : "Mirko") << el;
}
}
/*
8 8
...).).*
*....)..
.)*(..).
(*)((...
.)).)(..
.)(.)..(
...).(.*
M.......
*/
//
//110000
//1100
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |