Submission #500331

#TimeUsernameProblemLanguageResultExecution timeMemory
500331talant117408Speedrun (RMI21_speedrun)C++17
100 / 100
231 ms920 KiB
#include "speedrun.h" #include <bits/stdc++.h> //~ #include <ext/pb_ds/assoc_container.hpp> //~ using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; //~ typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) ll((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; const int MAXN = 1e3+7; vector <int> graph[MAXN]; int parent[MAXN]; vector <int> stacc, used(MAXN); int n; int len; void set_to_child(int from, int to) { for (int bit = 0; bit < 10; bit++) { if (to & (1 << bit)) { setHint(from, bit+1, 1); } else { setHint(from, bit+1, 0); } } } void set_to_parent(int from, int to) { for (int bit = 0; bit < 10; bit++) { if (to & (1 << bit)) { setHint(from, bit+11, 1); } else { setHint(from, bit+11, 0); } } } void set_dfs(int v, int p = 0) { if (used[v]) { return; } parent[v] = p; used[v] = 1; stacc.pb(v); for (auto to : graph[v]) { set_dfs(to, v); } } void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */ setHintLen(20); n = N; for (int i = 1; i < n; i++) { graph[A[i]].pb(B[i]); graph[B[i]].pb(A[i]); } set_dfs(1); for (int i = 0; i < sz(stacc); i++) { set_to_child(stacc[i], stacc[(i+1)%n]); set_to_parent(stacc[i], parent[stacc[i]]); } } int get_child() { int res = 0; for (int bit = 0; bit < 10; bit++) { if (getHint(bit+1)) { res += (1 << bit); } } return res; } int get_parent() { int res = 0; for (int bit = 0; bit < 10; bit++) { if (getHint(bit+11)) { res += (1 << bit); } } return res; } /* 5 1 2 2 3 3 4 3 5 2 */ void speedrun(int subtask, int N, int start) { /* your solution here */ len = getLength(); set <int> st; while (start != 1) { start = get_parent(); goTo(get_parent()); } int nxt = 0; while (sz(st) < N) { st.insert(start); if (nxt) { while (!goTo(nxt)) { goTo(get_parent()); } start = nxt; nxt = 0; } else { auto ch = get_child(); if (!goTo(ch)) { nxt = ch; } else { start = ch; } } } }
#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...