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>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 10010;
const int PW = (1 << 20);
vector<int> g[N];
int n, m, mt[N];
bool used[N];
bool try_kuhn(int v){
if (used[v]) return 0;
used[v] = 1;
for (int u : g[v])
if (mt[u] == -1 || try_kuhn(u)){
mt[u] = v;
return 1;
}
return 0;
}
bool good(int v){
if (used[v]) return 0;
used[v] = 1;
for (int u : g[v])
if (mt[u] == -1 || good(mt[u]))
return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m;
for (int i = 0; i < m; i++){
int x, y; cin >> x >> y;
x--; y--; y += n;
g[x].PB(y);
g[y].PB(x);
}
fill(mt, mt + n + n, -1);
for (int v = 0; v < n; v++){
fill(used, used + n + n, 0);
try_kuhn(v);
}
for (int v = n; v < n + n; v++)
if (mt[v] >= 0)
mt[mt[v]] = v;
for (int v = 0; v < n; v++)
if (mt[v] < 0)
cout << "Mirko\n";
else {
fill(used, used + n + n, 0);
cout << (good(mt[v]) ? "Mirko\n" : "Slavko\n");
}
return 0;
}
# | 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... |