#include<bits/stdc++.h>
#include<string>
using namespace std;
#define S second
#define F first
#define pb push_back
#define MP make_pair
#define ll long long
#define PAIR pair <ll ,ll >
#define reversee(x) reverse(x.begin(), x.end());
#define sortt(x) sort(x.begin(), x.end());
#define flash ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cout(l) cout<<fixed<<setprecision(10)<<l;
const ll maxn=1e3+10, mod=1e9+7 , inf=2e9 , lg=20;
ll mark[maxn] , match[maxn] , fmatch[maxn];
vector<ll> adj[maxn];
bool dfs(ll v){
mark[v]=1;
for(auto u:adj[v]){
if(match[u]==-1 || (!mark[match[u]] && dfs(match[u]))) {
match[u]=v;
return 1;
}
}
return 0;
}
int main(){
ll n , m;
cin>>n>>m;
for(int i=0;i<m;i++){
ll x, y;
cin>>x>>y;
x-- , y--;
adj[x].pb(y);
}
memset(match , -1 , sizeof(match));
bool flag=1;
while(flag){
flag=0;
memset(mark , 0 , sizeof(mark));
for(int i=0;i<n;i++){
if(!fmatch[i] && dfs(i)){
flag=fmatch[i]=1;
}
}
}
for(int i=0;i<n;i++){
if(!fmatch[i]){
dfs(i);
}
}
for(int i=0;i<n;i++){
if(mark[i]) cout<<"Mirko"<<endl;
else cout<<"Slavko"<<endl;
}
}
Compilation message
planinarenje.cpp: In function 'int main()':
planinarenje.cpp:45:31: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
45 | flag=fmatch[i]=1;
| ~~~~~~~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
460 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
588 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |