답안 #282864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282864 2020-08-25T05:29:53 Z 송준혁(#5748) Sleepy game (innopolis2018_final_D) C++17
36 / 100
2000 ms 54848 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, M, S;
vector<int> adj[101010];
int P[202020];
bool D[202020], cyc[202020], chk[202020], vis[202020];

void dfs(int u){
	if (vis[u]) return;
	if (u > N && adj[u-N].empty()){
		D[u] = 1;
		return;
	}
	vis[u] = chk[u] = true;
	if (u > N){
		for (int v : adj[u-N]){
			dfs(v);
			if (D[v]) D[u] = true, P[u] = v;
			if (chk[v] || cyc[v]) cyc[u] = true;
		}
	}
	else{
		for (int v : adj[u]){
			dfs(v+N);
			if (D[v+N]) D[u] = true, P[u] = v+N;
			if (chk[v+N] || cyc[v+N]) cyc[u] = true;
		}
	}
	chk[u] = false;
}

int main(){
	scanf("%d %*d", &N);
	for (int i=1; i<=N; i++){
		scanf("%d", &M);
		for (int j=1; j<=M; j++){
			int x;
			scanf("%d", &x);
			adj[i].push_back(x);
		}
	}
	scanf("%d", &S);
	dfs(S);
	if (D[S]){
		puts("Win");
		for (int u=S; u; u=P[u]){
			if (u>N) printf("%d ", u-N);
			else printf("%d ", u);
		}
		printf("\n");
	}
	else if (cyc[S]) puts("Draw");
	else puts("Lose");
	return 0;
}

Compilation message

D.cpp: In function 'int main()':
D.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |  scanf("%d %*d", &N);
      |  ~~~~~^~~~~~~~~~~~~~
D.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |   scanf("%d", &M);
      |   ~~~~~^~~~~~~~~~
D.cpp:41:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |    scanf("%d", &x);
      |    ~~~~~^~~~~~~~~~
D.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |  scanf("%d", &S);
      |  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Correct 2 ms 2688 KB Correct solution.
3 Correct 2 ms 2688 KB Correct solution.
4 Correct 49 ms 9996 KB Correct solution.
5 Correct 26 ms 6904 KB Correct solution.
6 Correct 39 ms 8056 KB Correct solution.
7 Correct 70 ms 12792 KB Correct solution.
8 Correct 65 ms 13816 KB Correct solution.
9 Correct 55 ms 11384 KB Correct solution.
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Correct 2 ms 2688 KB Correct solution.
3 Correct 2 ms 2688 KB Correct solution.
4 Correct 56 ms 5880 KB Correct solution.
5 Correct 2 ms 2688 KB Correct solution.
6 Correct 9 ms 3584 KB Correct solution.
7 Correct 87 ms 10220 KB Correct solution.
8 Correct 68 ms 10484 KB Correct solution.
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Correct solution.
2 Correct 2 ms 2688 KB Correct solution.
3 Correct 3 ms 2688 KB Correct solution.
4 Correct 3 ms 2688 KB Correct solution.
5 Execution timed out 2072 ms 54848 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Correct solution.
2 Correct 2 ms 2688 KB Correct solution.
3 Correct 3 ms 2688 KB Correct solution.
4 Correct 3 ms 2688 KB Correct solution.
5 Execution timed out 2072 ms 54848 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Correct 2 ms 2688 KB Correct solution.
3 Correct 2 ms 2688 KB Correct solution.
4 Correct 49 ms 9996 KB Correct solution.
5 Correct 26 ms 6904 KB Correct solution.
6 Correct 39 ms 8056 KB Correct solution.
7 Correct 70 ms 12792 KB Correct solution.
8 Correct 65 ms 13816 KB Correct solution.
9 Correct 55 ms 11384 KB Correct solution.
10 Correct 2 ms 2688 KB Correct solution.
11 Correct 2 ms 2688 KB Correct solution.
12 Correct 2 ms 2688 KB Correct solution.
13 Correct 56 ms 5880 KB Correct solution.
14 Correct 2 ms 2688 KB Correct solution.
15 Correct 9 ms 3584 KB Correct solution.
16 Correct 87 ms 10220 KB Correct solution.
17 Correct 68 ms 10484 KB Correct solution.
18 Correct 3 ms 2688 KB Correct solution.
19 Correct 2 ms 2688 KB Correct solution.
20 Correct 3 ms 2688 KB Correct solution.
21 Correct 3 ms 2688 KB Correct solution.
22 Execution timed out 2072 ms 54848 KB Time limit exceeded
23 Halted 0 ms 0 KB -