# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42733 | AryanSM | Planinarenje (COCI18_planinarenje) | C++14 | 11 ms | 6568 KiB |
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;
#define int long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
int match[M],match2[M];
vector<int>adj[M];
bool good[M],mark[M];
bool dfs(int v)
{
mark[v]=1;
for(int i=0;i<adj[v].size();i++)
{
int u=adj[v][i];
if(!match[u] || (!mark[match[u]] && dfs(match[u])))
{
match[u]=v;
match2[v]=u;
return 1;
}
}
return 0;
}
void dfs_check(int v)
{
good[v]=1;
for(int i=0;i<adj[v].size();i++)
{
int u=adj[v][i];
if(!good[match[u]])dfs_check(match[u]);
}
}
main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int a,b;
cin>>a>>b;
adj[a].pb(b);
}
while(true)
{
bool fin=0;
for(int i=1;i<=n;i++)mark[i]=0;
for(int i=1;i<=n;i++)
{
if(!mark[i] && !match2[i])
{
if(dfs(i))fin=1;
}
}
if(!fin)break;
}
for(int i=1;i<=n;i++)
{
if(!match2[i])dfs_check(i);
}
for(int i=1;i<=n;i++)
{
if(!good[i])cout<<"Slavko";
else cout<<"Mirko";
cout<<"\n";
}
}
Compilation message (stderr)
# | 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... |