Submission #149275

# Submission time Handle Problem Language Result Execution time Memory
149275 2019-09-01T06:06:32 Z お前はもう死んでいる(#3784, kuroni, nvmdava, tfg) Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 296 KB
#include "bulb.h"
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;
			swap(l[u], r[u]);
			for (int v = 0; v >= 0; v = (v == u ? r[v] : l[v]))
				if (!dive(r[v], l))
				{
					ok1 = false;
					break;
				}
			swap(l[u], r[u]);
			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:13: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 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 296 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 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 296 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 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -