Submission #1018971

# Submission time Handle Problem Language Result Execution time Memory
1018971 2024-07-10T11:26:14 Z vjudge1 Planinarenje (COCI18_planinarenje) C++17
48 / 160
9 ms 1020 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=10005;
int const mod=1e9+7;
int n,m;
vector<int> adj[N];
bool state[N];
bool vis[N];
void dfs(int node,int par){
	if(node<=n)
		state[node]=1;
	vis[node]=1;
	for(int i:adj[node]){
		if(i!=par && vis[i]==0)
			dfs(i,node);
	}
	if(node<=n){
		for(int i:adj[node])
			if(i!=par && state[i]==0){
				state[node]=0;
				return;
			}
	}
	else{
		for(int i:adj[node])
			if(i!=par && state[i]==1){
				state[node]=1;
				return;
			}
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		b+=n;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=2*n;j++){
			state[i]=0;
			vis[i]=0;
		}
		dfs(i,0);
		if(state[i])
			cout<<"Mirko"<<endl;
		else
			cout<<"Slavko"<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 808 KB Output is correct
2 Correct 7 ms 1020 KB Output is correct
3 Correct 8 ms 980 KB Output is correct
4 Correct 9 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -