Submission #113228

# Submission time Handle Problem Language Result Execution time Memory
113228 2019-05-24T11:32:41 Z 김세빈(#2857) Sleepy game (innopolis2018_final_D) C++14
17 / 100
96 ms 7388 KB
#include <bits/stdc++.h>

using namespace std;

vector <int> V[101010], Q;
int D[101010], P[101010];
bool chk[101010], ans[101010], dis[101010];
int n, m, s;

int main()
{
	int i, a, b, p;
	bool f = 0;
	
	scanf("%d%d", &n, &m);
	
	for(i=1; i<=n; i++){
		scanf("%d", &a);
		for(; a--; ){
			scanf("%d", &b);
			V[b].push_back(i);
			D[i] ++;
		}
		
		if(!D[i]){
			chk[i] = 1; ans[i] = 0;
			Q.push_back(i);
		}
	}
	
	for(; !Q.empty(); ){
		p = Q.back(); Q.pop_back();
		for(int &t: V[p]) if(!chk[t]){
			chk[t] = 1; ans[t] = 1; P[t] = p;
			for(int &x: V[t]) if(!chk[x]){
				D[x] --;
				if(D[x] == 0){
					chk[x] = 1; ans[x] = 0; P[x] = t;
					Q.push_back(x);
				}
			}
		}
	}
	
	scanf("%d", &s);
/*	
	if(ans[s]){
		printf("Win\n");
		for(; s; s=P[s]) printf("%d ", s);
		printf("\n");
		return 0;
	}
*/	
	for(i=1; i<=n; i++){
		for(int &t: V[i]) if(t == s) {
			dis[i] = 1;
			break;
		}
	}
	
	for(i=1; i<=n; i++){
		for(int &t: V[i]) if(dis[t]){
			if(ans[i]){
				printf("Win\n%d %d", s, t);
				for(s=i; s; s=P[s]) printf(" %d", s);
				printf("\n");
				return 0;
			}
			else if(!chk[i]) f = 1;
			break;
		}
	}
	
	if(f) printf("Draw\n");
	else printf("Lose\n");
	
	return 0;
}

Compilation message

D.cpp: In function 'int main()':
D.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
D.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
   ~~~~~^~~~~~~~~~
D.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &b);
    ~~~~~^~~~~~~~~~
D.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &s);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Correct solution.
2 Correct 4 ms 2688 KB Correct solution.
3 Correct 4 ms 2688 KB Correct solution.
4 Correct 36 ms 5888 KB Correct solution.
5 Correct 33 ms 4708 KB Correct solution.
6 Correct 38 ms 5628 KB Correct solution.
7 Correct 96 ms 7388 KB Correct solution.
8 Correct 44 ms 6264 KB Correct solution.
9 Correct 45 ms 6264 KB Correct solution.
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2688 KB Correct solution.
2 Incorrect 5 ms 2816 KB Participant's answer is Lose, but jury's is Win.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Correct solution.
2 Correct 5 ms 2688 KB Correct solution.
3 Correct 3 ms 2688 KB Correct solution.
4 Correct 4 ms 2688 KB Correct solution.
5 Correct 4 ms 2688 KB Correct solution.
6 Correct 5 ms 2816 KB Correct solution.
7 Incorrect 5 ms 2816 KB Participant's answer is Lose, but jury's is Win.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Correct solution.
2 Correct 5 ms 2688 KB Correct solution.
3 Correct 3 ms 2688 KB Correct solution.
4 Correct 4 ms 2688 KB Correct solution.
5 Correct 4 ms 2688 KB Correct solution.
6 Correct 5 ms 2816 KB Correct solution.
7 Incorrect 5 ms 2816 KB Participant's answer is Lose, but jury's is Win.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Correct solution.
2 Correct 4 ms 2688 KB Correct solution.
3 Correct 4 ms 2688 KB Correct solution.
4 Correct 36 ms 5888 KB Correct solution.
5 Correct 33 ms 4708 KB Correct solution.
6 Correct 38 ms 5628 KB Correct solution.
7 Correct 96 ms 7388 KB Correct solution.
8 Correct 44 ms 6264 KB Correct solution.
9 Correct 45 ms 6264 KB Correct solution.
10 Correct 5 ms 2688 KB Correct solution.
11 Incorrect 5 ms 2816 KB Participant's answer is Lose, but jury's is Win.
12 Halted 0 ms 0 KB -