Submission #100715

# Submission time Handle Problem Language Result Execution time Memory
100715 2019-03-13T15:27:21 Z Bodo171 The Big Prize (IOI17_prize) C++14
20 / 100
70 ms 6068 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);
     }
    }
    poz++;spec[st+1]=poz;
}
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 11 ms 5880 KB Output is correct
2 Correct 10 ms 5752 KB Output is correct
3 Correct 10 ms 5804 KB Output is correct
4 Correct 13 ms 5800 KB Output is correct
5 Correct 9 ms 5908 KB Output is correct
6 Correct 12 ms 5800 KB Output is correct
7 Correct 9 ms 5916 KB Output is correct
8 Correct 12 ms 5776 KB Output is correct
9 Correct 12 ms 5752 KB Output is correct
10 Correct 12 ms 5760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5912 KB Output is correct
2 Correct 11 ms 5884 KB Output is correct
3 Correct 12 ms 5808 KB Output is correct
4 Correct 12 ms 5880 KB Output is correct
5 Correct 8 ms 5804 KB Output is correct
6 Correct 11 ms 5760 KB Output is correct
7 Correct 8 ms 5908 KB Output is correct
8 Correct 11 ms 5756 KB Output is correct
9 Correct 9 ms 5800 KB Output is correct
10 Correct 11 ms 5896 KB Output is correct
11 Correct 13 ms 5852 KB Output is correct
12 Correct 17 ms 5800 KB Output is correct
13 Correct 17 ms 5824 KB Output is correct
14 Correct 17 ms 5120 KB Output is correct
15 Partially correct 67 ms 6016 KB Partially correct - number of queries: 8228
16 Partially correct 70 ms 6060 KB Partially correct - number of queries: 8568
17 Correct 12 ms 5752 KB Output is correct
18 Partially correct 54 ms 6008 KB Partially correct - number of queries: 6053
19 Correct 11 ms 5800 KB Output is correct
20 Partially correct 46 ms 5500 KB Partially correct - number of queries: 5536
21 Partially correct 57 ms 5880 KB Partially correct - number of queries: 5741
22 Partially correct 30 ms 6068 KB Partially correct - number of queries: 6223
23 Correct 10 ms 5896 KB Output is correct
24 Correct 16 ms 5880 KB Output is correct
25 Partially correct 58 ms 5928 KB Partially correct - number of queries: 6628
26 Incorrect 60 ms 5904 KB answer is not correct
27 Halted 0 ms 0 KB -