Submission #144162

# Submission time Handle Problem Language Result Execution time Memory
144162 2019-08-16T08:33:20 Z Abelyan Segway (COI19_segway) C++17
100 / 100
235 ms 79676 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=1e6+10;
const ll MOD2=998244353;
const ll MOD=1e9+7;


int acc[N],a[N][3];

int get(int i,int st,int en){
    int patas=0;
    FOR(j,3){
        patas+=max(0,min((j+1)*100,en)-max(st,j*100))*a[i][j];
        //cout<<"hey "<<min((i+1)*100,en)<<" "<<max(st,i*100)<<endl;
    }
    return patas;
}

int qan[306],ans[N],myus[N];
vector<pair<pair<int,int> ,bool> > jam[50*300*10];
int main(){
    fastio;
    srng;
    int n;
    cin>>n;
    FOR(i,n){
        FOR(j,3)cin>>a[i][j];
    }
    int m;
    cin>>m;
    FOR(i,m){
        int k;
        cin>>k;
        acc[k]=true;
    }
    acc[300]=true;
    int vrj=300;
    FORD(i,300){
        myus[i]=vrj;
        if (acc[i])vrj=i;
    }
    FOR(i,n){
        jam[get(i,0,myus[0])].ad({{i,myus[0]},true});
        //cout<<i<<" "<<myus[0]<<" "<<get(i,0,myus[0])<<endl;
    }
    FOR(i,300*50+6){
        trav(tv,jam[i]){
            //cout<<i<<" "<<tv.fr.fr<<" "<<tv.fr.sc<<" "<<tv.sc<<endl;
            if (tv.fr.sc==300){
                ans[tv.fr.fr]=i;
                continue;
            }
            if (tv.sc){
                int gnal=qan[tv.fr.sc]%20;
                int has=tv.fr.sc+gnal;
                bool bl=false;
                FORT(j,tv.fr.sc+1,has){
                    if (acc[j] && j==has){
                        jam[j-tv.fr.sc+i].ad({{tv.fr.fr,j},true});
                        bl=true;
                        break;
                    }
                    if (acc[j])jam[j-tv.fr.sc+i].ad({{tv.fr.fr,j},false});
                    if (j==300)break;
                }

                if (has>=300 || bl)continue;
                jam[gnal+i+get(tv.fr.fr,has,myus[has])].ad({{tv.fr.fr,myus[has]},true});
            }
        }
        trav(tv,jam[i]){
            qan[tv.fr.sc]++;
        }
    }
    FOR(i,n)cout<<ans[i]<<endl;
    return 0;
}
/*
7 2 8
C 1
C 2
C 3
C 4
C 5
C 6
O 7
O 7

*/
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3960 KB Output is correct
2 Correct 6 ms 3832 KB Output is correct
3 Correct 8 ms 3960 KB Output is correct
4 Correct 14 ms 4088 KB Output is correct
5 Correct 65 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3832 KB Output is correct
2 Correct 5 ms 3960 KB Output is correct
3 Correct 7 ms 3960 KB Output is correct
4 Correct 8 ms 3960 KB Output is correct
5 Correct 7 ms 3960 KB Output is correct
6 Correct 6 ms 4216 KB Output is correct
7 Correct 6 ms 3960 KB Output is correct
8 Correct 6 ms 3960 KB Output is correct
9 Correct 7 ms 4216 KB Output is correct
10 Correct 7 ms 4088 KB Output is correct
11 Correct 9 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3960 KB Output is correct
2 Correct 6 ms 3832 KB Output is correct
3 Correct 8 ms 3960 KB Output is correct
4 Correct 14 ms 4088 KB Output is correct
5 Correct 65 ms 5112 KB Output is correct
6 Correct 5 ms 3832 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 7 ms 3960 KB Output is correct
9 Correct 8 ms 3960 KB Output is correct
10 Correct 7 ms 3960 KB Output is correct
11 Correct 6 ms 4216 KB Output is correct
12 Correct 6 ms 3960 KB Output is correct
13 Correct 6 ms 3960 KB Output is correct
14 Correct 7 ms 4216 KB Output is correct
15 Correct 7 ms 4088 KB Output is correct
16 Correct 9 ms 4984 KB Output is correct
17 Correct 8 ms 3960 KB Output is correct
18 Correct 30 ms 12280 KB Output is correct
19 Correct 67 ms 16364 KB Output is correct
20 Correct 47 ms 6392 KB Output is correct
21 Correct 113 ms 26400 KB Output is correct
22 Correct 186 ms 53788 KB Output is correct
23 Correct 235 ms 79676 KB Output is correct