Submission #536974

# Submission time Handle Problem Language Result Execution time Memory
536974 2022-03-14T08:33:53 Z zaneyu Speedrun (RMI21_speedrun) C++14
71 / 100
230 ms 928 KB
#include "speedrun.h"
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define MNTO(x,y) x=min(x,y)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define ld long double
#define sz(x) (int)x.size()
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define unq(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn=2e3+5;
using namespace std;
vector<int> v[maxn];
void dfs(int u,int p){
	REP(j,10) setHint(u,j+1,(p&(1<<j))>>j);
	if(u>1){
		v[u].erase(find(ALL(v[u]),p));
	}
	if(sz(v[u])) REP(j,10) setHint(u,j+11,(v[u][0]&(1<<j))>>j);
	REP(j,sz(v[u])){
		int x=v[u][j];
		int nxt=u;
		if(j<sz(v[u])-1) nxt=v[u][j+1];
		REP(j,10) setHint(x,j+21,(nxt&(1<<j))>>j);
		dfs(x,u);
	}
}
void dfs3(int u,int p){
	REP(j,10) setHint(u,j+1,(p&(1<<j))>>j);
	if(p!=1023){
		v[u].erase(find(ALL(v[u]),p));
	}
	if(sz(v[u])) REP(j,10) setHint(u,j+11,(v[u][0]&(1<<j))>>j);
	else REP(j,10) setHint(u,j+11,0);
	REP(j,sz(v[u])){
		int x=v[u][j];
		dfs3(x,u);
	}
}
void assignHints(int subtask, int n, int A[], int B[]) {
	REP1(i,n-1){
		v[A[i]].pb(B[i]);
		v[B[i]].pb(A[i]);
	}
	if(subtask==2){
		setHintLen(20);
		REP1(i,n){
			if(sz(v[i])==n-1){
				REP1(a,n) REP(j,10) setHint(a,j+1,(i&(1<<j))>>j);
			}
		}
		return;
	}
	if(subtask==3){
		setHintLen(20);
		REP1(i,n){
			if(sz(v[i])==1){
				dfs(i,1023);
				return;
			}
		}
	}
	setHintLen(30);

	dfs(1,1023);
}
void gotoo(int x){
	if(x==0) assert(false);
	goTo(x);
}
void dfs2(int u){
	int p=0;
	REP(j,10) p=(p<<1)+getHint(10-j);
	int x=0;
	REP(j,10) x=(x<<1)+getHint(20-j);
	if(x==0){
		gotoo(p);
		return;
	}
	while(x!=u){
		gotoo(x);
		int nx=0;
		REP(j,10) nx=(nx<<1)+getHint(30-j);
		dfs2(x);
		x=nx;
	}
	if(u!=1) gotoo(p);
}
void dfs4(int u){
	int x=0;
	REP(j,10) x=(x<<1)+getHint(20-j);
	if(x==0){
		return;
	}
	goTo(x);
	dfs4(x);
}
void speedrun(int subtask, int n, int start) {
	if(subtask==2){
		int p=0;
		REP(j,10) p=(p<<1)+getHint(10-j);
		goTo(p);
		REP1(i,n){
			goTo(i);
			goTo(p);
		}
		return;
	}
	if(subtask==3){
		while(true){
			int p=0;
			REP(j,10) p=(p<<1)+getHint(10-j);
			if(p==1023) break;
			goTo(p);
			start=p;
		}
		dfs4(start);
		return;
	}
	while(start!=1){
		int p=0;
		REP(j,10) p=(p<<1)+getHint(10-j);
		gotoo(p);
		start=p;
	}
	dfs2(1);
}
# Verdict Execution time Memory Grader output
1 Correct 193 ms 672 KB Output is correct
2 Correct 200 ms 900 KB Output is correct
3 Correct 217 ms 796 KB Output is correct
4 Correct 173 ms 928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 676 KB Output is correct
2 Correct 89 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 680 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 193 ms 672 KB Output is correct
2 Correct 230 ms 712 KB Output is correct
3 Correct 152 ms 724 KB Output is correct
4 Correct 134 ms 792 KB Output is correct
5 Correct 203 ms 900 KB Output is correct
6 Correct 151 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 196 ms 680 KB Partial solution
2 Partially correct 198 ms 812 KB Partial solution
3 Partially correct 165 ms 672 KB Partial solution
4 Partially correct 199 ms 824 KB Partial solution
5 Partially correct 134 ms 724 KB Partial solution
6 Partially correct 208 ms 672 KB Partial solution
7 Partially correct 164 ms 708 KB Partial solution