Submission #480925

# Submission time Handle Problem Language Result Execution time Memory
480925 2021-10-18T19:46:31 Z DJeniUp Toll (BOI17_toll) C++17
25 / 100
3000 ms 10724 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,pairll>pairlll;
typedef pair<pairll,pairll>pairllll;
typedef long double ld;
typedef pair<ll,string>pairls;

#define INF 1000000000000007
#define MOD 1000000007
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

ll k,n,m,o,res[10007],t[50007][7];

vector<pairll>v[50007];

struct D{
    ll l,r,q;
}d[10007];

bool mcp(D d1, D d2){
    return d1.l<d2.l;
}

int main() {
    
    cin>>k>>n>>m>>o;
    for(int i=1;i<=m;i++){
        ll l,r,c;
        cin>>l>>r>>c;
        v[r].pb({l,c});
    }
    for(int i=1;i<=o;i++){
        cin>>d[i].l>>d[i].r;
        d[i].q=i;
    }
    sort(d+1,d+1+o,mcp);
    ll x=0;
    for(int i=1;i<=o;i++){
        if(d[i].l/k!=d[i-1].l/k || i==1){
            x=d[i].l-d[i].l%k;
            for(int j=0;j<k;j++){
                t[x][j]=t[x+1][j]=t[x+2][j]=t[x+3][j]=t[x+4][j]=INF;
            }
            t[x][0]=t[x+1][1]=t[x+2][2]=t[x+3][3]=t[x+4][4]=0;
            for(int j=x+k;j<n;j++){
                for(int y=0;y<k;y++){
                    t[j][y]=INF;
                    for(auto it: v[j]){
                        t[j][y]=min(t[j][y],t[it.fr][y]+it.sc);
                    }
                }
            }
        }
        if(d[i].l>d[i].r || t[d[i].r][d[i].l%k]==INF)res[d[i].q]=-1;
        else res[d[i].q]=t[d[i].r][d[i].l%k];
    }
    for(int i=1;i<=o;i++){
        cout<<res[i]<<endl;
    }

}
# Verdict Execution time Memory Grader output
1 Correct 2185 ms 7048 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 1 ms 1484 KB Output is correct
4 Correct 1 ms 1476 KB Output is correct
5 Correct 5 ms 1612 KB Output is correct
6 Correct 4 ms 1612 KB Output is correct
7 Correct 4 ms 1612 KB Output is correct
8 Correct 1932 ms 6976 KB Output is correct
9 Correct 1913 ms 6864 KB Output is correct
10 Correct 575 ms 4608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 8644 KB Output is correct
2 Correct 1 ms 1476 KB Output is correct
3 Correct 1 ms 1484 KB Output is correct
4 Correct 1 ms 1480 KB Output is correct
5 Correct 1 ms 1480 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 8 ms 1948 KB Output is correct
8 Correct 9 ms 1996 KB Output is correct
9 Correct 55 ms 6868 KB Output is correct
10 Correct 146 ms 10724 KB Output is correct
11 Correct 109 ms 8856 KB Output is correct
12 Correct 76 ms 7748 KB Output is correct
13 Correct 145 ms 10128 KB Output is correct
14 Correct 87 ms 7204 KB Output is correct
15 Correct 77 ms 6468 KB Output is correct
16 Correct 71 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 1 ms 1476 KB Output is correct
4 Correct 1 ms 1484 KB Output is correct
5 Correct 1 ms 1484 KB Output is correct
6 Correct 2 ms 1484 KB Output is correct
7 Correct 3 ms 1612 KB Output is correct
8 Correct 6 ms 1740 KB Output is correct
9 Correct 8 ms 1612 KB Output is correct
10 Correct 70 ms 6544 KB Output is correct
11 Correct 144 ms 8184 KB Output is correct
12 Correct 237 ms 10000 KB Output is correct
13 Correct 307 ms 10496 KB Output is correct
14 Correct 196 ms 9160 KB Output is correct
15 Correct 141 ms 6200 KB Output is correct
16 Correct 143 ms 6200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 1 ms 1476 KB Output is correct
4 Correct 1 ms 1484 KB Output is correct
5 Correct 1 ms 1484 KB Output is correct
6 Correct 2 ms 1484 KB Output is correct
7 Correct 3 ms 1612 KB Output is correct
8 Correct 6 ms 1740 KB Output is correct
9 Correct 8 ms 1612 KB Output is correct
10 Correct 70 ms 6544 KB Output is correct
11 Correct 144 ms 8184 KB Output is correct
12 Correct 237 ms 10000 KB Output is correct
13 Correct 307 ms 10496 KB Output is correct
14 Correct 196 ms 9160 KB Output is correct
15 Correct 141 ms 6200 KB Output is correct
16 Correct 143 ms 6200 KB Output is correct
17 Correct 1676 ms 8408 KB Output is correct
18 Correct 1 ms 1476 KB Output is correct
19 Correct 1 ms 1484 KB Output is correct
20 Correct 1 ms 1480 KB Output is correct
21 Correct 1 ms 1484 KB Output is correct
22 Correct 1 ms 1484 KB Output is correct
23 Correct 7 ms 1612 KB Output is correct
24 Correct 7 ms 1740 KB Output is correct
25 Correct 10 ms 1868 KB Output is correct
26 Correct 9 ms 1740 KB Output is correct
27 Correct 733 ms 6748 KB Output is correct
28 Correct 2978 ms 10232 KB Output is correct
29 Execution timed out 3067 ms 10532 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2185 ms 7048 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 1 ms 1484 KB Output is correct
4 Correct 1 ms 1476 KB Output is correct
5 Correct 5 ms 1612 KB Output is correct
6 Correct 4 ms 1612 KB Output is correct
7 Correct 4 ms 1612 KB Output is correct
8 Correct 1932 ms 6976 KB Output is correct
9 Correct 1913 ms 6864 KB Output is correct
10 Correct 575 ms 4608 KB Output is correct
11 Correct 99 ms 8644 KB Output is correct
12 Correct 1 ms 1476 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1 ms 1480 KB Output is correct
15 Correct 1 ms 1480 KB Output is correct
16 Correct 1 ms 1484 KB Output is correct
17 Correct 8 ms 1948 KB Output is correct
18 Correct 9 ms 1996 KB Output is correct
19 Correct 55 ms 6868 KB Output is correct
20 Correct 146 ms 10724 KB Output is correct
21 Correct 109 ms 8856 KB Output is correct
22 Correct 76 ms 7748 KB Output is correct
23 Correct 145 ms 10128 KB Output is correct
24 Correct 87 ms 7204 KB Output is correct
25 Correct 77 ms 6468 KB Output is correct
26 Correct 71 ms 6348 KB Output is correct
27 Correct 1 ms 1484 KB Output is correct
28 Correct 1 ms 1484 KB Output is correct
29 Correct 1 ms 1476 KB Output is correct
30 Correct 1 ms 1484 KB Output is correct
31 Correct 1 ms 1484 KB Output is correct
32 Correct 2 ms 1484 KB Output is correct
33 Correct 3 ms 1612 KB Output is correct
34 Correct 6 ms 1740 KB Output is correct
35 Correct 8 ms 1612 KB Output is correct
36 Correct 70 ms 6544 KB Output is correct
37 Correct 144 ms 8184 KB Output is correct
38 Correct 237 ms 10000 KB Output is correct
39 Correct 307 ms 10496 KB Output is correct
40 Correct 196 ms 9160 KB Output is correct
41 Correct 141 ms 6200 KB Output is correct
42 Correct 143 ms 6200 KB Output is correct
43 Correct 1676 ms 8408 KB Output is correct
44 Correct 1 ms 1476 KB Output is correct
45 Correct 1 ms 1484 KB Output is correct
46 Correct 1 ms 1480 KB Output is correct
47 Correct 1 ms 1484 KB Output is correct
48 Correct 1 ms 1484 KB Output is correct
49 Correct 7 ms 1612 KB Output is correct
50 Correct 7 ms 1740 KB Output is correct
51 Correct 10 ms 1868 KB Output is correct
52 Correct 9 ms 1740 KB Output is correct
53 Correct 733 ms 6748 KB Output is correct
54 Correct 2978 ms 10232 KB Output is correct
55 Execution timed out 3067 ms 10532 KB Time limit exceeded
56 Halted 0 ms 0 KB -