Submission #538049

#TimeUsernameProblemLanguageResultExecution timeMemory
538049TaylorSwiftFangirlSpeedrun (RMI21_speedrun)C++17
27 / 100
181 ms868 KiB
#include <bits/stdc++.h> #include "speedrun.h" using namespace std; int read(int place) { int ans = 0; for(int i=0; i<10; i++) { ans*=2; ans += getHint(place*10+i+1); } return ans; } void write(int x, int place, int v) { for(int i=0; i<10; i++) { setHint(x, place*10+i+1, v&(1<<(9-i))); } } vector<int> adj[1004]; deque<int> unreached; void dfs(int x, int p) { write(x, 0, p); int counter = 0; for(auto i : adj[x]) { if(i==p) continue; if(counter==0) write(x, 1, i); else unreached.push_back(i); counter++; } for(auto i : adj[x]) { if(i==p) continue; dfs(i, x); } if(adj[x].size()==1 && unreached.size()>0) { write(x, 1, unreached.front()); unreached.pop_front(); } } void assignHints(int st, 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); } void speedrun(int st, int n, int start) { int curr = start; while(curr != 1) { int par = read(0); goTo(par); curr = par; } vector<int> depth{1}; while(true) { int child = read(1); if(child == 0) break; if(goTo(child)) { depth.push_back(child); } else { while(true){ depth.pop_back(); goTo(depth.back()); if(goTo(child)) { depth.push_back(child); break; } } } } }
#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...