#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 200101
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 2> a2;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mt[N];
bool mrk[N];
vector <int> g[N];
bool kuna(int v)
{
if (mrk[v]) return 0;
mrk[v] = 1;
for (auto it : g[v])
if (mt[it] == -1 || kuna(mt[it])) {mt[it] = v; return 1;}
return 0;
}
bool gdr(int v)
{
if (mrk[v]) return 0;
mrk[v] = 1;
for (auto it : g[v])
if (mt[it] == -1 || gdr(mt[it])) return 1;
return 0;
}
int main()
{
//freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int x, y;
cin >> x >> y;
y += n;
g[x].pb(y);
g[y].pb(x);
}
for (int i = 1; i <= n + n; i++) mt[i] = -1;
for (int i = 1; i <= n; i++)
{
memset(mrk, 0, sizeof(mrk));
kuna(i);
}
for (int i = n + 1; i <= n + n; i++)
if (mt[i] != -1) mt[mt[i]] = i;
for (int i = 1; i <= n; i++)
if (mt[i] == -1) cout << "Mirko" << endl;
else
{
memset(mrk, 0, sizeof(mrk));
bool gd = gdr(mt[i]);
if (gd) cout << "Mirko" << endl;
else cout << "Slavko" << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5248 KB |
Output is correct |
2 |
Correct |
7 ms |
5248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5248 KB |
Output is correct |
2 |
Correct |
7 ms |
5248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5248 KB |
Output is correct |
2 |
Correct |
7 ms |
5248 KB |
Output is correct |
3 |
Correct |
8 ms |
5248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
5248 KB |
Output is correct |
2 |
Correct |
12 ms |
5248 KB |
Output is correct |
3 |
Correct |
13 ms |
5248 KB |
Output is correct |
4 |
Correct |
13 ms |
5248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
5504 KB |
Output is correct |
2 |
Correct |
66 ms |
5580 KB |
Output is correct |
3 |
Correct |
76 ms |
5504 KB |
Output is correct |
4 |
Correct |
67 ms |
5624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
5376 KB |
Output is correct |
2 |
Correct |
28 ms |
5376 KB |
Output is correct |
3 |
Correct |
26 ms |
5376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
5376 KB |
Output is correct |
2 |
Correct |
19 ms |
5376 KB |
Output is correct |
3 |
Correct |
27 ms |
5376 KB |
Output is correct |
4 |
Correct |
22 ms |
5376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
5376 KB |
Output is correct |
2 |
Correct |
63 ms |
5624 KB |
Output is correct |
3 |
Correct |
40 ms |
5504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
5376 KB |
Output is correct |
2 |
Correct |
49 ms |
5504 KB |
Output is correct |
3 |
Correct |
35 ms |
5496 KB |
Output is correct |
4 |
Correct |
49 ms |
5376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
5476 KB |
Output is correct |
2 |
Correct |
34 ms |
5476 KB |
Output is correct |
3 |
Correct |
53 ms |
5504 KB |
Output is correct |
4 |
Correct |
45 ms |
5376 KB |
Output is correct |