Submission #571075

# Submission time Handle Problem Language Result Execution time Memory
571075 2022-06-01T08:19:55 Z Theo830 Speedrun (RMI21_speedrun) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define ull unsigned ll
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "speedrun.h"
vector<vll>adj;
ll par[1005];
ll tim = 0;
ll tin[1005] = {0};
ll arr[1005] = {0};
ll next[1005];
void dfs(ll idx,ll p){
    par[idx] = p;
    tin[idx] = tim;
    arr[tim] = idx;
    tim++;
    for(auto x:adj[idx]){
        if(x != p){
            dfs(x,idx);
        }
    }
}
void assignHints(int subtask, int N, int A[], int B[]){
    setHintLen(20);
    adj.assign(N+5,vll());
    f(i,1,N){
        adj[A[i]].pb(B[i]);
        adj[B[i]].pb(A[i]);
    }
    dfs(1,0);
    f(i,1,N+1){
        next[i] = arr[tin[i] + 1];
    }
    f(i,1,N+1){
        f(j,0,10){
            if(par[i] & (1LL<<j)){
                setHint(i,j,1);
            }
            if(next[i] & (1LL<<j)){
                setHint(i,j + 10,1);
            }
        }
    }
}
void speedrun(int subtask, int N, int start){
    ll cur = start;
    while(cur != 1){
        cur = 0;
        f(j,0,10){
            if(getHint(j)){
                cur += (1LL<<j);
            }
        }
        assert(goTo(cur));
    }
    ll next = 0;
    f(j,0,10){
        if(getHint(j + 10)){
            next += (1LL<<j);
        }
    }
    while(next != 0){
        if(goTo(next)){
            next = 0;
            f(j,0,10){
                if(getHint(j + 10)){
                    next += (1LL<<j);
                }
            }
        }
        else{
            cur = 0;
            f(j,0,10){
                if(getHint(j)){
                    cur += (1LL<<j);
                }
            }
        }
    }
}

Compilation message

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:53:9: error: reference to 'next' is ambiguous
   53 |         next[i] = arr[tin[i] + 1];
      |         ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from speedrun.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
speedrun.cpp:32:4: note:                 'll next [1005]'
   32 | ll next[1005];
      |    ^~~~
speedrun.cpp:60:16: error: reference to 'next' is ambiguous
   60 |             if(next[i] & (1LL<<j)){
      |                ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from speedrun.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
speedrun.cpp:32:4: note:                 'll next [1005]'
   32 | ll next[1005];
      |    ^~~~