# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
996626 | 8pete8 | Speedrun (RMI21_speedrun) | C++17 | 1 ms | 344 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.
/*
I love you you love me
MIXUE Ice cream and tea
I love you you love me
MIXUE Ice cream and tea
I love you you love me
I love you you love me
MIXUE Ice cream and tea
*/
#include "speedrun.h"
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
vector<int>adj[1001];
int up[1001],go[1001];
int dfs(int cur,int p){
int last=cur;
for(auto i:adj[cur]){
if(i==p)continue;
go[last]=i;
up[i]=cur;
last=dfs(i,cur);
}
return last;
}
void assignHints(int subtask, int N, int A[], int B[]){
for(int i=1;i<N;i++){
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
}
setHintLen(20);
dfs(1,-1);
for(int i=1;i<=N;i++){
int x=up[i];
for(int j=0;j<10;j++)setHint(i,j,(x&(1LL<<j)));
x=go[i];
for(int j=0;j<10;j++)setHint(i,j+10,(x&(1LL<<j)));
}
return;
//go left and comeback
}
void speedrun(int subtask, int N, int start){
vector<int>up(N+1,0),go(N+1,0);
auto get=[&](int st){
int val=0;
for(int j=0;j<10;j++)if(getHint(j+st))val+=((1LL<<j));
return val;
};
int cur=start;
while(cur!=1){
if(cur==0)break;
up[cur]=get(0);
goTo(up[cur]);
cur=up[cur];
}
stack<int>st;
while(1){
st.push(cur);
int nx=get(10);
if(nx==0)break;
while(!goTo(nx))st.pop(),goTo(st.top());
cur=nx;
}
}
/*
5
1 2
2 3
3 4
3 5
*/
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... |