Submission #871552

#TimeUsernameProblemLanguageResultExecution timeMemory
871552TAhmed33Speedrun (RMI21_speedrun)C++17
0 / 100
102 ms1196 KiB
#include <bits/stdc++.h> #include "speedrun.h" using namespace std; vector <int> conv (int x) { vector <int> dd; for (int i = 9; i >= 0; i--) { dd.push_back((x >> i) & 1); } return dd; } void assignHints (int subtask, int n, int a[], int b[]) { vector <int> adj[n + 1]; for (int i = 1; i < n; i++) { adj[a[i]].push_back(b[i]); adj[b[i]].push_back(a[i]); } setHintLen(20); for (int i = 1; i <= n; i++) { auto d = conv(adj[i][0]); for (int l = 1; l <= 10; l++) { setHint(i, l, d[l - 1]); } if (adj[i].size() == 1) continue; d = conv(adj[i][1]); for (int l = 1; l <= 10; l++) { setHint(i, l + 10, d[l - 1]); } } } int n; void dfs (int pos, int par) { if (pos == 6) exit(0); int x = 0; for (int i = 1; i <= 10; i++) { x *= 2; x += getHint(i); } if (x != 0 && x != par) { goTo(x); dfs(x, pos); goTo(pos); } x = 0; for (int i = 11; i <= 20; i++) { x *= 2; x += getHint(i); } if (x != 0 && x != par) { goTo(x); dfs(x, pos); goTo(pos); } } void speedrun (int subtask, int N, int start) { dfs(start, -1); }
#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...