답안 #113259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113259 2019-05-24T13:19:56 Z 김세빈(#2857) Sleepy game (innopolis2018_final_D) C++14
19 / 100
187 ms 19064 KB
#include <bits/stdc++.h>

using namespace std;

vector <int> V1[202020], V2[101010];
queue <int> Q;
int P[202020];
bool chk[202020], fin[202020];
int n, m, s;

void dfs(int p)
{
	chk[p] = 1;
	
	for(int &t: V2[p]){
		if(!chk[t]){
			dfs(t);
		}
		else if(!fin[t]){
			printf("Draw\n");
			exit(0);
		}
	}
	
	fin[p] = 1;
}

int main()
{
	int i, a, b, p;
	
	scanf("%d%d", &n, &m);
	
	for(i=1; i<=n; i++){
		scanf("%d", &a);
		
		if(a == 0){
			chk[i - 1 << 1 | 1] = 1; P[i - 1 << 1 | 1] = -1;
			Q.push(i - 1 << 1 | 1);
		}
		
		for(; a--; ){
			scanf("%d", &b);
			V1[b - 1 << 1].push_back(i - 1 << 1 | 1);
			V1[b - 1 << 1 | 1].push_back(i - 1 << 1);
			V2[i].push_back(b);
		}
	}
	
	scanf("%d", &s);
	
	for(; !Q.empty(); ){
		p = Q.front(); Q.pop();
		for(int &t: V1[p]){
			if(!chk[t]){
				chk[t] = 1; P[t] = p;
				Q.push(t);
			}
		}
	}
	
	if(chk[s - 1 << 1]){
		printf("Win\n");
		for(i = s - 1 << 1; i != -1; i = P[i]){
			printf("%d ", (i >> 1) + 1);
		}
		printf("\n");
	}
	else{
		dfs(s);
		printf("Lose\n");
	}
	
	return 0;
}

Compilation message

D.cpp: In function 'int main()':
D.cpp:38:10: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    chk[i - 1 << 1 | 1] = 1; P[i - 1 << 1 | 1] = -1;
        ~~^~~
D.cpp:38:33: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    chk[i - 1 << 1 | 1] = 1; P[i - 1 << 1 | 1] = -1;
                               ~~^~~
D.cpp:39:13: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    Q.push(i - 1 << 1 | 1);
           ~~^~~
D.cpp:44:9: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    V1[b - 1 << 1].push_back(i - 1 << 1 | 1);
       ~~^~~
D.cpp:44:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    V1[b - 1 << 1].push_back(i - 1 << 1 | 1);
                             ~~^~~
D.cpp:45:9: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    V1[b - 1 << 1 | 1].push_back(i - 1 << 1);
       ~~^~~
D.cpp:45:35: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    V1[b - 1 << 1 | 1].push_back(i - 1 << 1);
                                 ~~^~~
D.cpp:62:11: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
  if(chk[s - 1 << 1]){
         ~~^~~
D.cpp:64:13: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   for(i = s - 1 << 1; i != -1; i = P[i]){
           ~~^~~
D.cpp:32: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:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
   ~~~~~^~~~~~~~~~
D.cpp:43:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &b);
    ~~~~~^~~~~~~~~~
D.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &s);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 7424 KB Participant's answer is Draw, but jury's is Lose.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Correct solution.
2 Correct 9 ms 7424 KB Correct solution.
3 Correct 10 ms 7444 KB Correct solution.
4 Correct 182 ms 16348 KB Correct solution.
5 Correct 8 ms 7424 KB Correct solution.
6 Correct 21 ms 8576 KB Correct solution.
7 Correct 187 ms 18452 KB Correct solution.
8 Correct 139 ms 19064 KB Correct solution.
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7424 KB Correct solution.
2 Correct 8 ms 7424 KB Correct solution.
3 Correct 8 ms 7460 KB Correct solution.
4 Correct 8 ms 7424 KB Correct solution.
5 Correct 8 ms 7424 KB Correct solution.
6 Correct 8 ms 7552 KB Correct solution.
7 Correct 9 ms 7552 KB Correct solution.
8 Correct 15 ms 7680 KB Correct solution.
9 Correct 9 ms 7552 KB Correct solution.
10 Correct 8 ms 7552 KB Correct solution.
11 Incorrect 8 ms 7552 KB Participant's answer is Draw, but jury's is Lose.
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7424 KB Correct solution.
2 Correct 8 ms 7424 KB Correct solution.
3 Correct 8 ms 7460 KB Correct solution.
4 Correct 8 ms 7424 KB Correct solution.
5 Correct 8 ms 7424 KB Correct solution.
6 Correct 8 ms 7552 KB Correct solution.
7 Correct 9 ms 7552 KB Correct solution.
8 Correct 15 ms 7680 KB Correct solution.
9 Correct 9 ms 7552 KB Correct solution.
10 Correct 8 ms 7552 KB Correct solution.
11 Incorrect 8 ms 7552 KB Participant's answer is Draw, but jury's is Lose.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 7424 KB Participant's answer is Draw, but jury's is Lose.
2 Halted 0 ms 0 KB -