Submission #644878

# Submission time Handle Problem Language Result Execution time Memory
644878 2022-09-25T12:13:26 Z PanTkd Speedrun (RMI21_speedrun) C++14
0 / 100
180 ms 712 KB
#include "speedrun.h"
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
 
using namespace std;
 
typedef int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#ifdef px
    #define p(x) cerr<<#x<<' '<<x<<endl;
#else
    #define p(x) {}
#endif
#define F first
#define S second
#define sz size
#define ls s,m,idx<<1
#define rs m+1,e,idx<<1|1
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
 
ll freq[20001];
ll arxi;
 
vector<vi> Adj;
vi Par,Son;
void dfs(ll s,ll p=0){
    for(auto x:Adj[s]){
        if(x!=p){
            Par[x]=s;
            Son[s]=x;
            dfs(x,s);
        }
    }
}
void assignHints(int subtask, int N, int A[], int B[]) { 
    setHintLen(20);
    Adj.assign(N+1,vi());
    Par.assign(N+1,0);
    Son.assign(N+1,0);
    for(ll i=1;i<N;i++){
        freq[A[i]]++;
        freq[B[i]]++;
        Adj[A[i]].push_back(B[i]);
        Adj[B[i]].push_back(A[i]);
    }
    for(ll i=1;i<=N;i++){
        if(freq[i]==1){
            arxi=i;
            break;
        }
    }
    p(arxi);
    Par[arxi]=0;
    Son[arxi]=0;
    ll curr=arxi;
    dfs(arxi,arxi);
    
    for(ll i=1;i<=N;i++){
        ll son=0,par=0;
        for(ll j=0;j<10;j++){
            if((1<<j)&Son[i]){
                setHint(i,j+1,1);
                son|=(1<<j);
            }else{
                setHint(i,j+1,0);
            }
            if((1<<j)&Par[i]){
                setHint(i,j+11,1);
                par|=(1<<j);
            }else{
                setHint(i,j+11,0);
            }
        }
        //cout<<i<<"->"<<son<<"<-"<<par<<endl;
        //cout<<i<<"->"<<Son[i]<<"<-"<<Par[i]<<endl;
    }
}
ll l;
 
 
void speedrun(int subtask, int N, int start) { /* your solution here */
    ll l=getLength();
 
    ll curr=start;
    while(curr!=0){
        p(curr);
        ll x=0;
        for(ll j=11;j<=20;j++){
            if(getHint(j))x|=(1<<(j-11));
        }
        curr=x;
        if(curr)
        goTo(curr);
    }
    //cerr<<endl;
    curr=arxi;
    //goTo(arxi);
    while(curr!=0){
        ll x=0;
        for(ll j=1;j<=10;j++){
            if(getHint(j))x|=(1<<(j-1));
        }
        p(curr);
        curr=x;
        if(curr)
        goTo(curr);
    }
}

Compilation message

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:73:8: warning: unused variable 'curr' [-Wunused-variable]
   73 |     ll curr=arxi;
      |        ^~~~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:100:8: warning: unused variable 'l' [-Wunused-variable]
  100 |     ll l=getLength();
      |        ^
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 672 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 712 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 620 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 180 ms 672 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 676 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -