답안 #764906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764906 2023-06-24T06:26:55 Z vjudge1 Speedrun (RMI21_speedrun) C++17
0 / 100
175 ms 672 KB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
const int MAXN=1e3+5;
vector<vector<int> > g(MAXN);
void assignHints(int subtask, int N, int A[], int B[]) {
	for(int i=1; i<=N; i++)g[i].clear();
	for(int i=1; i<N; i++) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	if(subtask==3) {
		setHintLen(20);
		vector<int> us(N+1, 0), pr(N+1, 0);
		queue<int> q;
		q.push(1);
		us[1]=1;
		while(!q.empty()) {
			int v=q.front();
			q.pop();
			for(int j=1; j<=10; j++) {
				setHint(v, j, (pr[v] & (1<<(j-1) ) ? 1 : 0) );
			}
			int cnt=0;
			for(auto to : g[v]) {
				if(!us[to]) {
					pr[to]=v;
					q.push(to);
					cnt++;
					if(cnt==2) {
						for(int j=11; j<=20; j++) {
							setHint(v, j, (to&(1<<(j-11)) ? 1 : 0));
						}
					}else {
						for(int j=1; j<=10; j++) {
							setHint(v, j, (to & (1<<(j-1) ) ? 1 : 0) );
						}
					}
					us[to]=1;
				}
			}
		}
	}
}
int Us[MAXN];
void dfs(int v, int p) {
	Us[v]=1;
	int x=0, y=0;
	for(int j=1; j<=10; j++) {
		if(getHint(j))x+=(1<<(j-1));
	}
	for(int j=11; j<=20; j++) {
		if(getHint(j))y+=(1<<(j-11));
	}
	if(x>0 && !Us[x]) {
		bool ok=goTo(x);
		if(ok)dfs(x, v);
		else {
			exit(0);
		}
	}
	if(y>0 && !Us[y]) {
		bool ok=goTo(y);
		if(ok)dfs(y, v);
		else {
			exit(0);
		}
	}
	if(p!=v)goTo(p);
	else return;
}
void speedrun(int subtask, int N, int start) {
	if(subtask==3) {
		for(int i=1; i<=N; i++)Us[i]=0;
		int l=getLength();
		dfs(start, start);
	}
}

Compilation message

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:75:7: warning: unused variable 'l' [-Wunused-variable]
   75 |   int l=getLength();
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 175 ms 672 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB setHintLen was never called
2 Halted 0 ms 0 KB -