답안 #282880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282880 2020-08-25T06:16:27 Z 임성재(#5752) Sleepy game (innopolis2018_final_D) C++17
19 / 100
89 ms 7540 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int n, m;
int in[100010];
vector<int> g[100010];
bool chk[200010];
int p[200010];
queue<int> q;

int main() {
	fast;

	cin >> n >> m;

	for(int i=1; i<=n; i++) {
		int out;
		cin >> out;

		for(int j=0; j<out; j++) {
			int v;
			cin >> v;

			g[v].eb(i);
		}

		if(out == 0) {
			chk[i] = true;
			q.em(i);
		}
	}

	while(q.size()) {
		int x = q.front();
		q.pop();

		int st = 0;

		if(x > n) {
			x -= n;
			st = 1;
		}

		for(auto i : g[x]) {
			if(chk[i + (1 - st) * n]) continue;
			
			p[i + (1 - st) * n] = x + st * n;
			chk[i + (1 - st) * n] = true;
			q.em(i + (1 - st) * n);
		}
	}

	int s;
	cin >> s;

	if(chk[s + n]) {
		cout << "Win\n";

		for(int i = s + n; i; i = p[i]) {
			cout << (i-1) % n + 1 << " ";
		}
	}
	else {
		cout << "Lose\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Incorrect 2 ms 2688 KB Participant's answer is Lose, but jury's is Draw.
3 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 81 ms 6396 KB Correct solution.
5 Correct 2 ms 2688 KB Correct solution.
6 Correct 7 ms 3200 KB Correct solution.
7 Correct 89 ms 7288 KB Correct solution.
8 Correct 50 ms 7540 KB Correct solution.
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Incorrect 2 ms 2688 KB Participant's answer is Lose, but jury's is Draw.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Incorrect 2 ms 2688 KB Participant's answer is Lose, but jury's is Draw.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Correct solution.
2 Incorrect 2 ms 2688 KB Participant's answer is Lose, but jury's is Draw.
3 Halted 0 ms 0 KB -