Submission #504696

# Submission time Handle Problem Language Result Execution time Memory
504696 2022-01-10T07:42:39 Z minhcool Speedrun (RMI21_speedrun) C++17
Compilation error
0 ms 0 KB
#include<speedrun.h>
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 1e3 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n;
vector<int> Adj[N];

int cnt;
int l[N], r[N], pos[N];
int par[N];
vector<int> path;

void dfs(int u, int p){
	cnt++;
	l[u] = pos[u] = cnt;
	path.pb(u);
	for(auto v : Adj[u]){
		if(v == p) continue;
		par[v] = u;
		dfs(v, u);
	}
	r[u] = cnt;
}

void assignHints(int subtask, int N, int A[], int B[]){
	n = N;
	for(int i = 1; i < n; i++){
		Adj[A[i]].pb(B[i]);
		Adj[B[i]].pb(A[i]);
	}
	dfs(1, 1);
	setHintLen(20);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			if(par[vc[i]] & (1LL << j)) setHint(vc[i], j + 1, 1);
			else setHint(vc[i], j + 1, 0);
		}
		int temp = vc[(i + 1) % n];
		for(int j = 0; j < 10; j++){
			if(temp & (1LL << j)) setHint(vc[i], j + 11, 1);
			else setHint(vc[i], j + 11, 0);
		}
	}
}

int get_par(){
	int ans = 0;
	for(int i = 0; i < 10; i++) if(getHint(i + 1)) ans += (1LL << i);
	return ans; 
}

int get_nxt(){
	int ans = 0;
	for(int i = 0; i < 10; i++) if(getHint(i + 11)) ans += (1LL << i);
	return ans;
}

void speedrun(int subtrask, int N, int start){
	int cur = start;
	for(int itr = 1; itr <= n; itr++){
		int nxt = get_nxt();
		if(nxt == 1){
			while(1){
				int temp = get_par();
				if(!temp) break;
				else goTo(temp);
			}
			continue;
		}
		while(1){
			if(goTo(nxt)) break;
			else goTo(get_par());
		}
	}
}

/*
void process(){

}

signed main(){
	ios_base::sync_with_stdio(0);
	process();
}*/

Compilation message

speedrun.cpp:18:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   18 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:50:11: error: 'vc' was not declared in this scope
   50 |    if(par[vc[i]] & (1LL << j)) setHint(vc[i], j + 1, 1);
      |           ^~
speedrun.cpp:53:14: error: 'vc' was not declared in this scope
   53 |   int temp = vc[(i + 1) % n];
      |              ^~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:74:6: warning: unused variable 'cur' [-Wunused-variable]
   74 |  int cur = start;
      |      ^~~