Submission #618050

# Submission time Handle Problem Language Result Execution time Memory
618050 2022-08-01T20:16:34 Z Dremix10 Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 304 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" - "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x) {}
    #define p2(x,y) {}
    #define pp(x) {}
    #define pv(x) {}
    #define ppv(x) {}
#endif
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const int N = 1e6+5;
const int MOD = 1e9+7;
const ll INF = 1e18+5;


long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
    ll dist[n][n] = {};
    l.push_back(0);

    int i,j,k;
    ll maxr[n] = {}, maxl[n] = {};

    for(i=0;i<n;i++){
        ll sum = d[i];
        //dist[i][i] = sum;
        //maxcol[i] = max(maxcol[i],sum);
        for(j=i+1;j<n;j++){
            sum += l[j-1];
            dist[i][j] = sum + d[j];
            maxr[j] = max(maxr[j],dist[i][j]);
            maxl[i] = max(maxl[i],dist[i][j]);
        }
    }

    ll suffl[n], box[n][n];
    suffl[n-1] = maxl[n-1];
    box[0][n-1] = dist[0][n-1];
    for(i=n-2;i>=0;i--){
        suffl[i] = max(suffl[i+1],maxl[i]);
        box[0][i] = max(box[0][i+1],dist[0][i]);
    }

    for(i=1;i<n;i++){
        ll maxi = 0;
        for(j=n-1;j>=0;j--){
            maxi = max(maxi,dist[i][j]);
            box[i][j] = max(box[i-1][j],maxi);
        }
    }
    
    ll ans = INF;
    ll beg = 0, fin;
    ll mids[n] = {};
    ll keep[n][n] = {};

    for(i=0;i<n;i++){
        beg = max(beg,maxr[i]);
        
        
        for(j=i+1;j<n;j++){
            fin = maxl[j];
            ll win = max(0ll,dist[i][j]-d[i]-d[j] - c);
            ll res = max({beg,fin,box[i][j]-win});

            // todo: beg goes to mid | mid goes to mid | mid goes to fin
            // beg goes to mid
            
            ll winbeg = win;

            for(k=j-1;k>i;k--){
                winbeg -= l[k]*2;
                winbeg = max(0ll,winbeg);
                res = max(res,mids[k]-winbeg);
            }

            ll winmid = win;

            // mid goes to mid
            
            for(k=i+1;k<j;k++){
                for(int o=k+1;o<j;o++){
                    res = max(res,min(dist[k][o],dist[i][k]+dist[o][j]-d[i]-d[j]+c));
                }
            }
            
            keep[i][j] = res;
            
            mids[j] = max(mids[j],dist[i][j]);
        }
        
    }
    ll mide[n]= {};
    //ll ans = 0;
    for(j=n-1;j>=0;j--){
        //beg = max(beg,maxr[i]);

        
        for(i=j-1;i>=0;i--){
            //fin = maxl[j];
            ll win = max(0ll,dist[i][j]-d[i]-d[j] - c);
            ll res = keep[i][j];

            // todo: beg goes to mid | mid goes to mid | mid goes to fin
            // beg goes to mid
            
            ll winbeg = win;

            for(k=i+1;k<j;k++){
                winbeg -= l[k-1]*2;
                winbeg = max(0ll,winbeg);
                res = max(res,mide[k]-winbeg);
            }
            /*
            ll winmid = win;

            // mid goes to mid
            
            for(k=i+1;k<j;k++){
                for(int o=k+1;o<j;o++){
                    res = max(res,min(dist[k][o],dist[i][k]+dist[o][j]-d[i]-d[j]+c));
                }
            }
            */
            if(res == 100){
                p2(i,j)
                p2(keep[i][j],res)
            }
            
            mide[i] = max(mide[i],dist[i][j]);
            ans = min(ans,res);
        }
        
    }
    return ans;

}

Compilation message

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:90:16: warning: unused variable 'winmid' [-Wunused-variable]
   90 |             ll winmid = win;
      |                ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 304 KB n = 3, 4 is a correct answer
5 Correct 0 ms 304 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 212 KB n = 3, 29 is a correct answer
8 Correct 0 ms 212 KB n = 2, 3 is a correct answer
9 Correct 0 ms 212 KB n = 2, 3 is a correct answer
10 Correct 1 ms 296 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 304 KB n = 3, 3000000000 is a correct answer
14 Correct 1 ms 300 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 212 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 212 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 296 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 296 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 296 KB n = 10, 7000000000 is a correct answer
20 Correct 1 ms 300 KB n = 5, 12 is a correct answer
21 Correct 1 ms 212 KB n = 5, 25 is a correct answer
22 Correct 0 ms 212 KB n = 2, 122 is a correct answer
23 Incorrect 0 ms 212 KB n = 10, incorrect answer: jury 117 vs contestant 110
24 Halted 0 ms 0 KB -