Submission #100716

# Submission time Handle Problem Language Result Execution time Memory
100716 2019-03-13T15:28:50 Z Bodo171 The Big Prize (IOI17_prize) C++14
20 / 100
67 ms 6136 KB
#include "prize.h"
#include <fstream>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;
const int nmax=200005;
const int prdf=500;//modifici dupa asta
int lg[nmax];
int spec[nmax];
int mx,nr,i,n;
vector<int> v[nmax];
int cate_st(int poz)
{
    if(v[poz].empty()) v[poz]=ask(poz);
    return v[poz][0];
}
int cate(int poz)
{
    if(v[poz].empty()) v[poz]=ask(poz);
    return (v[poz][0]+v[poz][1]);
}
pair<int,int> vezi_al_catelea(int x)
{
    int pp=0;
    while(x<n&&cate(x)<mx)
        x++;
    if(x==n) pp=mx;
    else pp=cate_st(x);
    x--;
    pair<int,int> ret;
    ret.second=pp;
    while(x>=0&&cate(x)<mx)
    {
       spec[pp]=x;
       pp--;x--;
    }
    ret.first=pp;
    return ret;
}
void solve(int st,int dr)
{
    if(st+1>=dr) return;
    int len=spec[dr]-spec[st];
    int poz=spec[st];
    for(int p=lg[len];p>=0;p--)
    {
        if(poz+(1<<p)<spec[dr])
     {
        if(cate(poz+(1<<p))<mx)
        {
            poz+=(1<<p);
            pair<int,int> pe=vezi_al_catelea(poz);
            solve(st,pe.first);solve(pe.second,dr);
            return;
        }
        if(cate_st(poz+(1<<p))==st&&cate(poz+(1<<p))==mx)
            poz+=(1<<p);
     }
    }
    spec[st+1]=poz+1;
}
int find_best(int N) {
    n=N;
    for(i=2;i<=n+1;i++)
        lg[i]=lg[i/2]+1;
    for(i=0;i<min(prdf,n);i++)
    {
        v[i]=ask(i);
        if(v[i][0]+v[i][1]>mx)
            mx=v[i][0]+v[i][1];
    }
    spec[0]=-1;
    for(i=0;i<min(prdf,n);i++)
    {
        if(v[i][0]+v[i][1]!=mx)
            {
                spec[++nr]=i;
                if(!cate(i)) return i;
            }

    }
    spec[mx+1]=n;
    solve(nr,mx+1);
    for(i=1;i<=mx;i++)
        if(cate(spec[i])==0)
           return spec[i];
	return 0;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:85:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=1;i<=mx;i++)
     ^~~
prize.cpp:88:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return 0;
  ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 5772 KB Output is correct
2 Correct 10 ms 5908 KB Output is correct
3 Correct 9 ms 5908 KB Output is correct
4 Correct 9 ms 5912 KB Output is correct
5 Correct 13 ms 5752 KB Output is correct
6 Correct 12 ms 5784 KB Output is correct
7 Correct 12 ms 5888 KB Output is correct
8 Correct 13 ms 5760 KB Output is correct
9 Correct 11 ms 5752 KB Output is correct
10 Correct 9 ms 5900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 5808 KB Output is correct
2 Correct 12 ms 5804 KB Output is correct
3 Correct 9 ms 5908 KB Output is correct
4 Correct 8 ms 5828 KB Output is correct
5 Correct 8 ms 5752 KB Output is correct
6 Correct 12 ms 5888 KB Output is correct
7 Correct 9 ms 5908 KB Output is correct
8 Correct 7 ms 5804 KB Output is correct
9 Correct 13 ms 5756 KB Output is correct
10 Correct 11 ms 5760 KB Output is correct
11 Correct 13 ms 5916 KB Output is correct
12 Correct 11 ms 5908 KB Output is correct
13 Correct 11 ms 5932 KB Output is correct
14 Correct 21 ms 5120 KB Output is correct
15 Partially correct 67 ms 6136 KB Partially correct - number of queries: 8228
16 Partially correct 51 ms 5996 KB Partially correct - number of queries: 8568
17 Correct 13 ms 5752 KB Output is correct
18 Partially correct 40 ms 5976 KB Partially correct - number of queries: 6053
19 Correct 8 ms 5800 KB Output is correct
20 Partially correct 54 ms 5624 KB Partially correct - number of queries: 5536
21 Partially correct 50 ms 5988 KB Partially correct - number of queries: 5741
22 Partially correct 48 ms 5988 KB Partially correct - number of queries: 6223
23 Correct 15 ms 5880 KB Output is correct
24 Correct 16 ms 5752 KB Output is correct
25 Partially correct 35 ms 6032 KB Partially correct - number of queries: 6628
26 Incorrect 32 ms 6108 KB answer is not correct
27 Halted 0 ms 0 KB -