Submission #842054

# Submission time Handle Problem Language Result Execution time Memory
842054 2023-09-02T10:51:42 Z vjudge1 Speedrun (RMI21_speedrun) C++17
29 / 100
57 ms 2128 KB
#include <bits/stdc++.h>
#include "speedrun.h"

using namespace std;
 
typedef long long ll;

// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
 
// Defines
 
#define pb push_back // kak push_back 5
#define endl '\n'
#define FOR(i,start,end) for(int i = start;i < end;i ++)
#define REV(i,start,end) for(int i = start;i >= end;i --)
#define precal(x) fixed << setprecision(x)
#define F first
#define S second
#define sz(x) (ll)x.size()
#define all(x) (x).begin(),(x).end()
#define m_p make_pair
#define mt make_tuple
#define str to_string

// #ifndef ONLINE_JUDGE
//     #define cerr if(false) cerr
// #endif
 

int k[1001][1001];

// void setHintLen(int l){

// }

// void setHint(int i, int j, bool b){

// }

// int getLength(){

// }

// bool getHint(int j){

// }

// bool goTo(int x){

// }

bool used[1001];

ll h[1001];

void dfs1(ll x,ll pr,ll start,ll N){
    used[x] = true;
    for(int i = 1;i <= N;i ++){
        if(used[i] == true) continue;
        bool check = getHint(i);
        if(check == true){
            bool t = goTo(i);
            dfs1(i,x,start,N);
        }
    }
    if(x == start) return;
    bool t = goTo(pr);
}

void assignHints(int subtask, int N, int A [], int B []){
    if(subtask == 1){
        setHintLen(N);
        for(int i = 1;i <= N - 1;i ++){
            setHint(A[i],B[i],true),setHint(B[i],A[i],true);
        }
    }
    if(subtask == 2){
        for(int i = 1;i <= N - 1;i ++){
            h[A[i]] ++,h[B[i]] ++;
        }
        ll pos = 0;
        for(int i = 1;i <= N;i ++){
            if(h[i] > 1){
                pos = i;
                break;
            }
        }
        ll len = ceil(log2(pos));
        setHintLen(len);
        for(int i = 1;i <= N - 1;i ++){
            if(A[i] == pos){
                ll cur = pos,l = len;
                while(cur > 0){
                    setHint(B[i],l,cur % 2);
                    l --,cur /= 2;
                }
            }
            else{
                ll cur = pos,l = len;
                while(cur > 0){
                    setHint(A[i],l,cur % 2);
                    l --,cur /= 2;
                }
            }
        }
    }
    return;
}

void speedrun(int subtask, int N, int start ){
    if(subtask == 1){
        int l = getLength(),pos = start;
        dfs1(start,start,start,N);
    }
    if(subtask == 2){
        int l = getLength();
        ll dg = 0,pos = 0;
        for(int i = l;i >= 1;i --){
            bool f = getHint(i);
            if(f == true) pos += (1 << dg);
            dg ++;
        }
        if(pos == 0){
            for(int i = 1;i <= N;i ++){
                if(i == start){
                    continue;
                }
                else{
                    goTo(i);
                    goTo(start);
                }
            }
        }
        else{
            goTo(pos);
            for(int i = 1;i <= N;i ++){
                if(i == pos) continue;
                goTo(i);
                goTo(pos);
            }
        }
    }
    return;
}

Compilation message

speedrun.cpp: In function 'void dfs1(ll, ll, ll, ll)':
speedrun.cpp:66:18: warning: unused variable 't' [-Wunused-variable]
   66 |             bool t = goTo(i);
      |                  ^
speedrun.cpp:71:10: warning: unused variable 't' [-Wunused-variable]
   71 |     bool t = goTo(pr);
      |          ^
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:116:13: warning: unused variable 'l' [-Wunused-variable]
  116 |         int l = getLength(),pos = start;
      |             ^
speedrun.cpp:116:29: warning: unused variable 'pos' [-Wunused-variable]
  116 |         int l = getLength(),pos = start;
      |                             ^~~
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1356 KB Output is correct
2 Correct 23 ms 2128 KB Output is correct
3 Correct 23 ms 1216 KB Output is correct
4 Correct 23 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1204 KB Output is correct
2 Correct 57 ms 1452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB setHintLen was never called
2 Halted 0 ms 0 KB -