Submission #833379

# Submission time Handle Problem Language Result Execution time Memory
833379 2023-08-22T05:08:22 Z RaulAndrei01 Speedrun (RMI21_speedrun) C++17
0 / 100
145 ms 748 KB
#include "speedrun.h"
#include <bits/stdc++.h>
#include <vector>
#include <stack>

using namespace std;
const int NMAX = 1001;
vector<int> adj[NMAX];
stack<int> ord;

void setPar (int nod , int par)
{
    int bit = 1;
    while (par)
    {
        setHint(nod , bit , par&1);
        bit++;
        par /= 2;
    }
}

void setNext (int nod , int nxt)
{
    int bit = 11;
    while (nxt)
    {
        setHint(nod , bit , nxt&1);
        bit++;
        nxt /= 2;
    }
}

void dfs (int nod = 1 , int par = 0)
{
    ord.push(nod);
    for (auto& to : adj[nod])
    {
        if (to == par) continue;
        setPar(to , nod);
        dfs(to , nod);
    }
}

void assignHints(int subtask, int N, int A[], int B[])
{
    setHintLen(20);
    for (int i = 1; i < N; i++)
    {
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
    }
    dfs();
    int prev = 1;
    while (ord.size())
    {
        setNext(ord.top() , prev);
        prev = ord.top();
        ord.pop();
    }
}

int getPar (int nod)
{
    int par = 0;
    for (int bit = 1; bit <= 10; bit++)
    {
        par = par << 1 + getHint(bit);
    }
    return par;
}

int getNext (int nod)
{
    int nxt = 0;
    for (int bit = 11; bit <= 20; bit++)
    {
        nxt = nxt << 1 + getHint(bit);
    }
    return nxt;
}

void speedrun(int subtask, int N, int start)
{
    vector<bool> viz(N+1, 0);
    int visited = 0;
    int crt = start;
    while (visited < N)
    {
        int par = getPar(crt);
        int nxt = getNext(crt);
        if (goTo(nxt) == 0) goTo(par);
    }
    
}

Compilation message

speedrun.cpp: In function 'int getPar(int)':
speedrun.cpp:67:24: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   67 |         par = par << 1 + getHint(bit);
      |                      ~~^~~~~~~~~~~~~~
speedrun.cpp: In function 'int getNext(int)':
speedrun.cpp:77:24: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   77 |         nxt = nxt << 1 + getHint(bit);
      |                      ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 672 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 672 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 748 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 145 ms 720 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 748 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -