답안 #644831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644831 2022-09-25T10:37:47 Z PanTkd Speedrun (RMI21_speedrun) C++14
0 / 100
1 ms 876 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 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]=arxi;
    Son[arxi]=arxi;
    ll curr=arxi;
    for(ll i=1;i<=N;i++){
        ll fst=Adj[curr][0];
        ll sec=arxi;
        if(curr!=arxi) sec=Adj[curr][1];
        if(!(fst==Par[curr])){
            Par[fst]=curr;
            Son[curr]=fst;
            curr=fst;
        }
        else if(!(sec==Par[curr])){
            Par[sec]=curr;
            Son[curr]=sec;
            curr=sec;
        }
    }
    

}
ll l;
void dfs(ll s,ll p=-1){
    for(ll i=1;i<=l;i++){
        if(i==p||i==s)continue;
        if(getHint(i)){
            goTo(i);
            dfs(i,s);
        }
    }
    goTo(p);
}

void speedrun(int subtask, int N, int start) { /* your solution here */
    if(start==arxi){
        ll curr=start;
        for(ll i=1;i<N;i++){
            curr=Son[curr];
            goTo(curr);
        }
    }
    else{
        ll curr=start;
        while(curr!=arxi){
            curr=Par[curr];
            goTo(curr);
        }

        for(ll i=1;i<N;i++){
            curr=Son[curr];
            goTo(curr);
        }
    }
}



# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -