Submission #299009

# Submission time Handle Problem Language Result Execution time Memory
299009 2020-09-14T12:10:02 Z TadijaSebez Planinarenje (COCI18_planinarenje) C++11
48 / 160
18 ms 1024 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=5050;
vector<int> E[N];
int mch[N];
bool was[N];
void cl(){for(int i=0;i<N;i++)was[i]=0;}
bool DFS(int u){
	if(was[u])return 0;
	was[u]=1;
	for(int v:E[u]){
		if(!mch[v]){
			mch[v]=u;
			return 1;
		}else{
			if(DFS(mch[v])){
				mch[u]=v;
				return 1;
			}
		}
	}
	return 0;
}
bool ok[N];
void EXP(int u){
	for(int v:E[u]){
		assert(mch[v]);
		if(ok[mch[v]]){
			ok[mch[v]]=0;
			EXP(mch[v]);
		}
	}
}
int main(){
	int n,m;
	scanf("%i %i",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%i %i",&u,&v);
		E[u].pb(v);
	}
	for(int i=1;i<=n;i++)cl(),ok[i]=DFS(i);
	for(int i=1;i<=n;i++)if(!ok[i])EXP(i);
	for(int i=1;i<=n;i++){
		if(ok[i])printf("Slavko\n");
		else printf("Mirko\n");
	}
	return 0;
}

Compilation message

planinarenje.cpp: In function 'int main()':
planinarenje.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |  scanf("%i %i",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~
planinarenje.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |   scanf("%i %i",&u,&v);
      |   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 716 KB Output is correct
2 Correct 16 ms 760 KB Output is correct
3 Correct 14 ms 640 KB Output is correct
4 Correct 15 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 896 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 1024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -