#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]) {
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 |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
468 KB |
Output is correct |
2 |
Correct |
3 ms |
468 KB |
Output is correct |
3 |
Correct |
4 ms |
600 KB |
Output is correct |
4 |
Correct |
4 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
499 ms |
1108 KB |
Output is correct |
2 |
Correct |
440 ms |
1140 KB |
Output is correct |
3 |
Correct |
386 ms |
972 KB |
Output is correct |
4 |
Correct |
427 ms |
988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
596 KB |
Output is correct |
2 |
Correct |
5 ms |
596 KB |
Output is correct |
3 |
Correct |
7 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
596 KB |
Output is correct |
2 |
Correct |
22 ms |
644 KB |
Output is correct |
3 |
Correct |
5 ms |
596 KB |
Output is correct |
4 |
Correct |
4 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
708 KB |
Output is correct |
2 |
Correct |
313 ms |
820 KB |
Output is correct |
3 |
Correct |
83 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
712 KB |
Output is correct |
2 |
Correct |
160 ms |
788 KB |
Output is correct |
3 |
Correct |
90 ms |
704 KB |
Output is correct |
4 |
Correct |
8 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
752 KB |
Output is correct |
2 |
Correct |
107 ms |
700 KB |
Output is correct |
3 |
Correct |
144 ms |
784 KB |
Output is correct |
4 |
Correct |
22 ms |
724 KB |
Output is correct |