# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538945 | ryangohca | Speedrun (RMI21_speedrun) | C++17 | 115 ms | 876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "speedrun.h"
#include <bits/stdc++.h>
//#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
vector<int> adjlist[1001];
string toBin(int x){
string ans = "";
while (x!=0){
ans += (x%2)+'0';
x /= 2;
}
return ans;
}
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
setHintLen(20);
int midNode = 0;
for (int i = 1; i < N; i++){
adjlist[A[i]].push_back(B[i]);
adjlist[B[i]].push_back(A[i]);
}
for (int i = 1; i <= N; i++){
if (adjlist[i].size() > 2) midNode = i;
}
string s = toBin(midNode);
for (int i = 1; i <= N; i++){
if (i == midNode) continue;
for (int j = 0; j < s.length(); j++){
setHint(i, j+1, s[j]-'0');
}
}
}
int fromBin(string x){
int p = 1;
int ans = 0;
for (int i = 0; i < x.length(); i++){
ans += (x[i] == '1'? p: 0);
p *= 2;
}
return ans;
}
void speedrun(int subtask, int N, int start) { /* your solution here */
int l = getLength();
string b = "";
for (int i = 1; i <= 20; i++){
b += getHint(i) + '0';
}
int x = fromBin(b);
if (x != 0) goTo(x);
else x = start;
for (int i = 1; i <= N; i++){
if (i != x){
goTo(i);
goTo(x);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |