Submission #860352

# Submission time Handle Problem Language Result Execution time Memory
860352 2023-10-12T17:28:20 Z ASN49K Speedrun (RMI21_speedrun) C++14
100 / 100
125 ms 2688 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++)
        {
            setHint(x,i+1,(tt&(1<<i))>0);
        }
        nodes.pb(x);
        for(auto &c:g[x])
        {
            if(c!=tt)
                dfs(c,x);
        }
    };
    dfs(1,0);
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<10;j++)
        {
            setHint(nodes[i-1],j+11,(nodes[i]&(1<<j))>0);
        }
    }
}
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());
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 91 ms 1640 KB Output is correct
2 Correct 107 ms 1876 KB Output is correct
3 Correct 104 ms 1876 KB Output is correct
4 Correct 112 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 1636 KB Output is correct
2 Correct 116 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 2144 KB Output is correct
2 Correct 122 ms 2688 KB Output is correct
3 Correct 125 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 1908 KB Output is correct
2 Correct 103 ms 1880 KB Output is correct
3 Correct 111 ms 1628 KB Output is correct
4 Correct 107 ms 1480 KB Output is correct
5 Correct 112 ms 1616 KB Output is correct
6 Correct 118 ms 1904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 1260 KB Output is correct
2 Correct 122 ms 1616 KB Output is correct
3 Correct 94 ms 2120 KB Output is correct
4 Correct 110 ms 1664 KB Output is correct
5 Correct 114 ms 1616 KB Output is correct
6 Correct 105 ms 1888 KB Output is correct
7 Correct 113 ms 1656 KB Output is correct