Submission #504844

# Submission time Handle Problem Language Result Execution time Memory
504844 2022-01-10T09:10:46 Z duchung Speedrun (RMI21_speedrun) C++17
0 / 100
234 ms 748 KB
#include<speedrun.h>

#include<bits/stdc++.h>
using namespace std;

const int N = 1005;

int timer = 0;
vector<int> edge[N];
int parent[N] , tin[N] , Euler[N];

void dfs(int u)
{
	tin[u] = ++timer;
	Euler[timer] = u;
	for (int v : edge[u])
	{
		if (v == parent[u]) continue;
		parent[v] = u;
		dfs(v);
	}
}

void assignHints (int subtask , int n , int eu[] , int ev[])
{
	for (int i = 1 ; i < n ; ++i)
	{
		edge[eu[i]].push_back(ev[i]);
		edge[ev[i]].push_back(eu[i]);
	}
	dfs(1);

	setHintLen(20);

	for (int u = 1 ; u <= n ; ++u)
	{
		int v;

		if (u != 1)
		{
			v = parent[u];
			for (int j = 0 ; j < 10 ; ++j) setHint(u , j + 1 , v >> j & 1);
		}

		if (tin[u] == n) v = 1; 
		else v = Euler[tin[u] + 1];
		for (int j = 0 ; j < 10 ; ++j) setHint(u , j + 11 , v >> j & 1);
	}
}

pair<int , int> Hint[N];

void speedrun(int subtask , int n , int cur)
{
	int l = getLength();

	int cnt = 1;
	while(cnt < n)
	{
		for (int j = 0 ; j < 10 ; ++j) if (getHint(j + 1)) Hint[cur].first ^= 1 << j;
		for (int j = 10 ; j < 20 ; ++j) if (getHint(j + 1)) Hint[cur].second ^= 1 << (j - 10);

		// cerr << cur << " " << Hint[cur].first << " " << Hint[cur].second << "\n";

		int tmp = Hint[cur].second;
		while (!goTo(tmp))
		{
			goTo(Hint[cur].first);
		}
		++cnt;
	}
}

Compilation message

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:55:6: warning: unused variable 'l' [-Wunused-variable]
   55 |  int l = getLength();
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 716 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 660 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 234 ms 660 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 168 ms 660 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 748 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -