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 debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <long double, pii> muchie;
const ll NMAX = 10001;
const ll VMAX = 101;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 447;
const ll base = 117;
const ll nr_of_bits = 18;
const ll inv2 = 500000004;
int match[NMAX];
vector <int> v[NMAX];
int viz[NMAX];
int restricted;
bool DFS(int node) {
viz[node] = 1;
if(node == restricted)
return 0;
for(auto x : v[node]) {
if(!match[x]) {
match[node] = x;
match[x] = node;
return 1;
}else if(!viz[match[x]] && DFS(match[x])){
match[node] = x;
match[x] = node;
return 1;
}
}
return 0;
}
int main() {
//ifstream cin(".in");
//ofstream cout(".out");
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, i, m;
cin >> n >> m;
for(i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
b += n;
v[a].push_back(b);
v[b].push_back(a);
}
int cuplajI = 0;
for(int j = 1; j <= n; j++) {
viz[j] = 0;
}
int ok = 1;
while(ok) {
ok = 0;
for(i = 1; i <= n; i++) viz[i] = 0;
for(i = 1; i <= n; i++) {
if(!viz[i] && !match[i]) {
debug(i);
ok |= DFS(i);
}
}
}
for(i = 1; i <= n; i++) {
cuplajI += (match[i] > 0);
}
for(i = 1; i <= n; i++) {
match[match[i]] = 0;
match[i] = 0;
restricted = i;
for(int j = 1; j <= n; j++) {
viz[j] = 0;
}
int ok = 1;
while(ok) {
ok = 0;
for(int peak = 1; peak <= n; peak++) {
viz[peak] = 0;
}
for(int peak = 1; peak <= n; peak++) {
if(!viz[peak] && !match[peak]) {
ok |= DFS(peak);
}
}
}
int cuplajA = 0;
for(int peak = 1; peak <= n; peak++) {
cuplajA += (match[peak] > 0);
}
if(cuplajA == cuplajI){
cout << "Mirko\n";
}else{
cout << "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... |