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>
using namespace std;
const int NMAX = 5010;
int cuplat[2 * NMAX];
vector <int> adia[2 * NMAX];
int viz[2 * NMAX];
bool cuplaj(int nod)
{
if (viz[nod])
return 0;
viz[nod] = 1;
for (auto i : adia[nod]) {
if (!cuplat[i]) {
cuplat[i] = nod;
cuplat[nod] = i;
return 1;
}
}
for (auto i : adia[nod]) {
if (cuplaj(cuplat[i])) {
cuplat[i] = nod;
cuplat[nod] = i;
return 1;
}
}
return 0;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, a, b;
cin >> n >> m;
while (m--) {
cin >> a >> b;
adia[a].push_back(b + n);
adia[b + n].push_back(a);
}
bool ok = 1;
while (ok) {
ok = 0;
memset(viz, 0, sizeof viz);
for (int i = 1; i <= n; i++)
if (!cuplat[i] && cuplaj(i))
ok = 1;
}
for (int i = 1; i <= n; i++) {
memset(viz, 0, sizeof viz);
if (!cuplat[i] || cuplaj(cuplat[i])) {
cuplat[i] = 0;
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... |