Submission #937357

# Submission time Handle Problem Language Result Execution time Memory
937357 2024-03-04T00:59:17 Z Neco_arc Toll (BOI17_toll) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <bits/debug.hpp>
#endif // ONLINE_JUDGE

#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define Neco "Toll"
#define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define getbit(x,i) ((x >> i)&1)
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define cntbit(x) __builtin_popcountll(x)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define maxn (int) 5e4 + 7

using namespace std;

const ll mod = 1e9 + 7; //972663749
const ll base = 911382323;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll GetRandom(ll l, ll r)
{
    return uniform_int_distribution<ll> (l, r)(rng);
}

int n, m, k, q;
int nex[maxn][20][5];
int dp[maxn][2];

int calc(int x, int y)
{
    int pre = 0, curr = 1;
    fi(i, 0, k - 1) dp[i][0] = dp[i][1] = 1e9;
    dp[x % k][0] = 0;

    int kc = y/k - x/k, layer = x/k;

    fi(t, 0, 20)
    {
        if(!getbit(kc, t)) continue;

        fi(u, 0, k - 1) fi(v, 0, k - 1)
        {
            int a = k * layer + u;
            dp[v][curr] = min(dp[v][curr], dp[u][pre] + nex[a][t][v]);
        }
        swap(pre, curr);
        layer += (1 << t);
        fi(i, 0, k - 1) dp[i][curr] = 1e9;
    }

    return dp[y % k][pre] >= 1e9 ? -1 : dp[y % k][pre];
}

void solve()
{
    memset(nex, 60, sizeof nex);
    cin >> k >> n >> m >> q;

    fi(i, 1, m) {
        int x, y, w;
        cin >> x >> y >> w;
        nex[x][0][y % k] = w;
    }

    fi(j, 1, 20) fi(i, 0, n)
    {
        int P = i / k;
        fi(u, 0, k - 1) fi(v, 0, k - 1)
        {
            int x = k * (P + (1 << (j - 1))) + u;
//            if(i == 0) cout << j << " " << u << " " << v << " " << x << '\n';
            if(x <= n) nex[i][j][v] = min(nex[i][j][v], nex[i][j - 1][u] + nex[x][j - 1][v]);
        }
    }

    fi(i, 1, q) {
        int x, y;
        cin >> x >> y;
        cout << calc(x, y) << '\n';
    }

}


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if(fopen(Neco".inp", "r")) {
        freopen(Neco".inp", "r", stdin);
        freopen(Neco".out", "w", stdout);
    }


    int nTest = 1;
//    cin >> nTest;


    while(nTest--)
    {
        solve();
    }


    return 0;
}

Compilation message

toll.cpp:3:10: fatal error: bits/debug.hpp: No such file or directory
    3 | #include <bits/debug.hpp>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.