Submission #66531

# Submission time Handle Problem Language Result Execution time Memory
66531 2018-08-11T10:31:06 Z MANcity Shortcut (IOI16_shortcut) C++14
0 / 100
3 ms 788 KB
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
#include "shortcut.h"
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
int n;
LL d[10002];
LL x[10002];
LL c;
struct req
{
    LL x;
    LL y;
    LL k;
};
int stug(LL k)
{
    vector<req> V;
    for1(i,n)
    {
        fo(j,i+1,n)
        {
            if(abs(x[i]-x[j])+d[i]+d[j]>k)
            {
                if((k-d[i]-d[j]-c)<0)
                    return 0;
                req t;
                t.x=x[i];
                t.y=x[j];
                t.k=k-d[i]-d[j]-c;
                V.push_back(t);
            }
        }
    }
    int R=V.size();
    if(R==0)
        return 1;
    vector<pair<LL,LL> > G;
    vector<pair<LL,LL> > E;
    for0(i,V.size()-1)
    {
        LL e=(V[i].x-V[i].k)-V[i].y;
        LL u=(V[i].x+V[i].k)-V[i].y;
        G.pb(mp(e,-1));
        G.pb(mp(u,1));
        e=V[i].y+V[i].k+V[i].x;
        u=V[i].y-V[i].k+V[i].x;
        E.pb(mp(u,-1));
        E.pb(mp(e,1));
    }
    sort(G.begin(),G.end());
    LL S=0;
    LL u=0;
    LL l;
    for0(i,G.size()-1)
    {
        S-=G[i].second;
        if(S==R)
        {
          u=1;
          l=G[i].first;
          break;
        }
    }
    if(u==0)
        return 0;
    sort(E.begin(),E.end());
    S=0;
    u=0;
    LL r;
    for0(i,E.size()-1)
    {
        S-=E[i].second;
        if(S==R)
        {
            u=1;
            r=E[i].first;
            break;
        }
    }
    if(u==0)
        return 0;
    if(abs(l-r)%2==0)
        return 1;
    return 0;
}
long long find_shortcut(int n_0, vector<int> l, vector<int> d_0, int c_0)
{
    c=c_0;
    n=n_0;
    LL ma=0;
    for1(i,n)
    {
        d[i]=d_0[i-1];
        ma=max(ma,d[i]);
    }
    x[1]=0;
    for0(i,l.size()-1)
        x[i+2]=x[i+1]+l[i];
    LL r=1000000000000000;
    LL l1=1;
    while(1)
    {
        if(r==(l1+1))
        {
            if(stug(l1)==1)
                return l1;
            return r;
        }
        if(l1==r)
            return l1;
        LL m=(l1+r)/2;
        if(stug(m)==1)
            r=m;
        else
            l1=(m+1);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 356 KB n = 9, 110 is a correct answer
3 Correct 2 ms 496 KB n = 4, 21 is a correct answer
4 Correct 2 ms 496 KB n = 3, 4 is a correct answer
5 Correct 2 ms 496 KB n = 2, 62 is a correct answer
6 Correct 2 ms 548 KB n = 2, 3 is a correct answer
7 Correct 3 ms 628 KB n = 3, 29 is a correct answer
8 Correct 2 ms 632 KB n = 2, 3 is a correct answer
9 Correct 2 ms 636 KB n = 2, 3 is a correct answer
10 Correct 3 ms 648 KB n = 2, 2000000001 is a correct answer
11 Correct 2 ms 648 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 656 KB n = 3, 3000000000 is a correct answer
14 Correct 2 ms 664 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 788 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 788 KB n = 5, 4000000000 is a correct answer
17 Incorrect 3 ms 788 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -