답안 #923968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923968 2024-02-08T07:07:18 Z Tyx2019 Speedrun (RMI21_speedrun) C++17
100 / 100
125 ms 1924 KB
#include <speedrun.h>
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1005];
vector<int> dfsorder;
int pararray[1005];
void dfs(int cur, int par){
    pararray[cur]=par;
    dfsorder.push_back(cur);
    for(auto newnode:adj[cur]){
        if(newnode!=par){
            dfs(newnode,cur);
        }
    }
}
void assignHints(int subtask, int N, int A[], int B[]) { 
    //cout << " am i gay " << endl;
    for(int i=1;i<N;i++){
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
    }
    //cout << "yes i am " << endl;
    dfs(1, 1023);
    //cout << "i eat kids" << endl;
    setHintLen(20);
    int nextinline[N+5];
    for(int i=1;i<N;i++){
        nextinline[dfsorder[i-1]]=dfsorder[i];
    }
    //cout << dfsorder.size() << endl;
    //cout << "Sorry i eat kids" << endl;
    nextinline[dfsorder[N-1]]=1023;
    //cout << "sorry what" << endl;
    for(int i=1;i<=N;i++){
        int paren=pararray[i];
        //cout << "PAREN " << paren << "\n";
        for(int j=1;j<=10;j++){
 
            if((paren&(1<<(j-1)))==0){
                setHint(i,j,false);
                //cout << i << " " << j << " FALSE\n";
            }
            else{
                setHint(i,j,true);
                //cout << i << " " << j << " "<< "TRUE\n";
            }
        }
        int nex=nextinline[i];
        for(int j=1;j<=10;j++){
            if((nex&(1<<(j-1)))==0) setHint(i,j+10,false);
            else setHint(i,j+10,true);
        }
    }
}
 
void speedrun(int subtask, int N, int start) {
    //Get to the root
    int cur=start;
    while(cur!=1){
        //cout << current_node << " curnode\n";
        int paren=0;
        int lol=1;
        for(int i=1;i<=10;i++){
            paren += getHint(i) * lol;
            lol *= 2;
        }
        if(goTo(paren)){
            cur=paren;
            continue;
        }
      	else{
          //cout << paren << " " << cur << endl;
          return;
        }
        cur=paren;
    }
    //cout << "im gay" << endl;
    int parens[N+5];
    for(int j=0;j<N-1;j++){
      	int par=0;
      	int lul=1;
      	for(int i=1;i<=10;i++){
          par += getHint(i)*lul;
          lul*=2;
        }
      	parens[cur]=par;
        int next=0;
        int lol=1;
        for(int i=11;i<=20;i++){
            next += getHint(i) * lol;
            lol *= 2;
        }
        if(goTo(next)){
          cur=next;
        }
        else{
            while(true){
                int backto=parens[cur];
                goTo(backto);
              	cur=backto;
                if(goTo(next)){
                  cur=next;
                  break;
                }
            }
        }
    }
    return;
    //Do the tour
}
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 1656 KB Output is correct
2 Correct 110 ms 1196 KB Output is correct
3 Correct 89 ms 1672 KB Output is correct
4 Correct 103 ms 1452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 1820 KB Output is correct
2 Correct 84 ms 1660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 952 KB Output is correct
2 Correct 92 ms 940 KB Output is correct
3 Correct 100 ms 1452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 1312 KB Output is correct
2 Correct 98 ms 1924 KB Output is correct
3 Correct 88 ms 1656 KB Output is correct
4 Correct 99 ms 1712 KB Output is correct
5 Correct 104 ms 1396 KB Output is correct
6 Correct 90 ms 1676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 940 KB Output is correct
2 Correct 112 ms 1680 KB Output is correct
3 Correct 109 ms 1404 KB Output is correct
4 Correct 108 ms 1200 KB Output is correct
5 Correct 106 ms 1568 KB Output is correct
6 Correct 115 ms 1584 KB Output is correct
7 Correct 91 ms 1588 KB Output is correct