Submission #149312

# Submission time Handle Problem Language Result Execution time Memory
149312 2019-09-01T06:12:17 Z お前はもう死んでいる(#3784, kuroni, nvmdava, tfg) Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 376 KB
#include "bulb.h"
#include <cstdio>
using namespace std;

int dive(int u, vector<int> &l)
{
	while (u >= 0)
		u = l[u];
	return u == -1;
}

int FindWinner(int t, vector<int> l, vector<int> r)
{
	int n = l.size();
	if (!dive(0, l))
		return 0;
	for (int u = 0; u >= 0; u = l[u])
		if (!dive(r[u], l))
		{
			bool ok1 = true, ok2 = true;
			for (int v = 0; v != l[u] && ok1; v = l[v])
				for (int k = r[v]; k >= 0; k = l[k])
				{
					if (!dive(r[k], l))
					{
						ok1 = false;
						break;
					}
				}
			if (r[u] >= 0)
			{
				swap(l[r[u]], r[r[u]]);
				for (int v = 0; v >= 0; v = (v == r[u] ? r[v] : l[v]))
					if (!dive(r[v], l))
					{
						ok2 = false;
						break;
					}
				swap(l[r[u]], r[r[u]]);
			}
			else
				ok2 = false;
			return ok1 || ok2;
		}
	return 1;
}

Compilation message

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:14:6: warning: unused variable 'n' [-Wunused-variable]
  int n = l.size();
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 256 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 256 KB Output isn't correct
11 Halted 0 ms 0 KB -