이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 5005 * 2;
int n, m;
vector<int> G[N];
bool seen[N], path[N], s[N];
bool dfs(int v)
{
seen[v] = path[v] = true;
bool dead = true, l = false;
for(int u : G[v])
{
if(seen[u] && path[u]) continue;
dead = false;
if(!seen[u])
s[u] = dfs(u);
l |= !s[u];
}
path[v] = false;
if(dead) return false;
return l;
}
int main()
{
cin >> n >> m;
for(int i = 0; i < m ; i++)
{
int u, v;
cin >> u >> v;
v += n;
G[u].push_back(v);
G[v].push_back(u);
}
for(int i = 1; i <= n; i ++)
{
cout << (dfs(i) ? "Slavko" : "Mirko") << "\n";
for(int j = 1; j <= 2 * n; j ++)
seen[j] = false;
}
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... |