Submission #1128459

#TimeUsernameProblemLanguageResultExecution timeMemory
1128459KasymKToll (BOI17_toll)C++20
46 / 100
3094 ms1660 KiB
// I want to go high as fuck tonight...
// Music name => (Gyzyl Ysyk)
// Authors: A$OK, SazYelme, Swizzy347 and Ma.Gallery
// Hash your favorite words.
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 5e4+5;
const int K = 5;
const int INF = 1e9;
int mal[N][K], dp[N];

int main(){
    // freopen("file.txt", "r", stdin);
    int k, n, m, q;
    scanf("%d%d%d%d", &k, &n, &m, &q);
    memset(mal, 65, sizeof mal);
    while(m--){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        mal[a][b%k]=c;
    }
    while(q--){
        int a, b;
        scanf("%d%d", &a, &b);
        dp[a]=0;
        for(int i = a+1; i <= b; ++i)
            dp[i]=INF;
        for(int i = a; i < (b/k)*k; ++i)
            for(int j = 0; j < k; ++j)
                umin(dp[(i/k)*k+k+j], dp[i]+mal[i][j]);
        if(dp[b]==INF)
            puts("-1");
        else
            printf("%d\n", dp[b]);
    }
    return 0;
}

Compilation message (stderr)

toll.cpp: In function 'int main()':
toll.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d%d%d%d", &k, &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d%d%d", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
toll.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...