답안 #860346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860346 2023-10-12T16:44:21 Z ASN49K Speedrun (RMI21_speedrun) C++14
0 / 100
73 ms 1876 KB
#include <bits/stdc++.h>
//#include "speedrun.h"
#define bug(a) std::cerr << "(" << #a << ": " << a << ")\n";
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
void setHintLen (int l);
void setHint(int i, int j, bool b);
int getLength ();
bool getHint(int j);
bool goTo(int x);
///////////////////////
void assignHints (int subtask , int n, int a[], int b[])
{
    vector<vector<int>>g(n+1);
    setHintLen(20);
    for(int i=1;i<n;i++)
    {
        g[a[i]].pb(b[i]);
        g[b[i]].pb(a[i]);
    }
    vector<int>nodes;
    function<void(int,int)>dfs=[&](int x,int tt)
    {
        for(int i=0;i<10;i++)
        {
            if(tt&(1<<i))
                setHint(x,i+1,1);
        }
        nodes.pb(x);
        for(auto &c:g[x])
        {
            if(c!=tt)
                dfs(c,x);
        }
    };
    dfs(1,0);
    nodes.pb(0);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<10;j++)
        {
            if(nodes[i]&(1<<j));
                setHint(nodes[i-1],j+11,1);
        }
    }
}
void speedrun(int subtask , int n, int x )
{
    auto tata=[&]()->int
    {
        int sol=0;
        for(int i=0;i<10;i++)
        {
            if(getHint(i+1))
            {
                sol|=(1<<i);
            }
        }
        return sol;
    };
    auto next=[&]()->int
    {
        int sol=0;
        for(int i=0;i<10;i++)
        {
            if(getHint(i+11))
            {
                sol|=(1<<i);
            }
        }
        return sol;
    };
    while(x!=1)
    {
        x=tata();
        goTo(x);
    }
    for(int i=1;i<n;i++)
    {
        int urm=next();
        while(!goTo(urm))
        {
            goTo(tata());
        }
    }
}

Compilation message

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:43:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   43 |             if(nodes[i]&(1<<j));
      |             ^~
speedrun.cpp:44:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   44 |                 setHint(nodes[i-1],j+11,1);
      |                 ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 1096 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 1100 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 66 ms 1876 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 1152 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 1152 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -