Submission #580073

#TimeUsernameProblemLanguageResultExecution timeMemory
580073FatihSolakSpeedrun (RMI21_speedrun)C++17
0 / 100
218 ms744 KiB
#include <bits/stdc++.h> #include "speedrun.h" #define N 1005 using namespace std; vector<int> adj[N]; bool sub[N]; void init(int v,int num1,int num2){ for(int i = 0;i<10;i++){ setHint(v,i+1,!!(num1 & (1<<(9-i)))); } for(int i = 0;i<10;i++){ setHint(v,i+11,!!(num2 & (1<<(9-i)))); } } void dfs(int v,int par,int num2){ //cout << v << " " << num2 << endl; int num1 = 0; for(auto u:adj[v]){ if(u == par)continue; if(num1 == 0)num1 = u; } int c = par; for(int i = adj[v].size()-1;i>=0;i--){ if(adj[v][i] == par)continue; dfs(adj[v][i],v,c); c = adj[v][i]; } init(v,num1,num2); } void assignHints(int subtask, int n, int A[], int B[]) { setHintLen(20); for(int i = 1;i<n;i++){ adj[A[i]].push_back(B[i]); adj[B[i]].push_back(A[i]); } dfs(1,0,0); } int get(int x){ int ret = 0; for(int i = 0;i<10;i++){ ret += getHint(i + 1 + 10 * (x-1)) * (1<<(9-i)); } return ret; } int go(int v){ if(sub[v]){ sub[v] = 2; return get(2); } sub[v] = 1; //cout << v << " " << get(1) << " " << get(2) << endl; int now = get(1); while(now){ goTo(now); now = go(now); if(sub[v] != 1) break; goTo(v); } return get(2); } void speedrun(int subtask, int n, int start) { go(start); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...