답안 #100722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100722 2019-03-13T16:08:58 Z Bodo171 커다란 상품 (IOI17_prize) C++14
90 / 100
96 ms 6148 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,gasit;
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);
    if(!(v[poz][0]+v[poz][1])) gasit=1;
    return (v[poz][0]+v[poz][1]);
}
int cate_dr(int poz)
{
    return (cate(poz)-cate_st(poz));
}
void solve(int st,int dr)
{
    if(st>dr) return;
    if(gasit) return;
    if(cate(st)<mx)
    {
        spec[++nr]=st;
        solve(st+1,dr);
        return;
    }
    if(cate(dr)<mx)
    {
        spec[++nr]=dr;
        solve(st,dr-1);
        return;
    }
    if(cate_st(st)+cate_dr(dr)==mx) return;
    int m=(st+dr)/2;
    if(cate(m)<mx)
    {
        spec[++nr]=m;
        solve(st,m-1);
        solve(m+1,dr);
    }
    else
    {
        if(cate_st(st)+cate_dr(m)!=mx) solve(st,m-1);
        if(cate_st(m)+cate_dr(dr)!=mx) solve(m+1,dr);
    }
}
int find_best(int 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)
            {
                if(!cate(i)) return i;
            }

    }
    spec[mx+1]=n;
    solve(prdf,n-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:78:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=1;i<=mx;i++)
     ^~~
prize.cpp:81:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return 0;
  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5880 KB Output is correct
2 Correct 10 ms 5880 KB Output is correct
3 Correct 9 ms 5908 KB Output is correct
4 Correct 11 ms 5880 KB Output is correct
5 Correct 11 ms 5800 KB Output is correct
6 Correct 10 ms 5760 KB Output is correct
7 Correct 10 ms 5760 KB Output is correct
8 Correct 9 ms 5908 KB Output is correct
9 Correct 12 ms 5772 KB Output is correct
10 Correct 13 ms 5880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 5760 KB Output is correct
2 Correct 15 ms 5752 KB Output is correct
3 Correct 13 ms 5760 KB Output is correct
4 Correct 12 ms 5796 KB Output is correct
5 Correct 14 ms 5880 KB Output is correct
6 Correct 14 ms 5800 KB Output is correct
7 Correct 9 ms 5800 KB Output is correct
8 Correct 18 ms 5856 KB Output is correct
9 Correct 12 ms 5900 KB Output is correct
10 Correct 12 ms 5760 KB Output is correct
11 Correct 12 ms 5916 KB Output is correct
12 Correct 11 ms 5780 KB Output is correct
13 Correct 18 ms 5880 KB Output is correct
14 Correct 12 ms 5120 KB Output is correct
15 Correct 21 ms 5880 KB Output is correct
16 Partially correct 46 ms 5892 KB Partially correct - number of queries: 6714
17 Correct 11 ms 5752 KB Output is correct
18 Partially correct 73 ms 6056 KB Partially correct - number of queries: 8010
19 Correct 10 ms 5888 KB Output is correct
20 Correct 16 ms 5584 KB Output is correct
21 Correct 25 ms 5992 KB Output is correct
22 Correct 14 ms 5936 KB Output is correct
23 Correct 14 ms 5796 KB Output is correct
24 Correct 8 ms 5808 KB Output is correct
25 Correct 38 ms 5880 KB Output is correct
26 Correct 46 ms 5876 KB Output is correct
27 Correct 10 ms 5916 KB Output is correct
28 Partially correct 58 ms 5972 KB Partially correct - number of queries: 6893
29 Partially correct 46 ms 5880 KB Partially correct - number of queries: 5467
30 Partially correct 68 ms 6036 KB Partially correct - number of queries: 7891
31 Correct 12 ms 5880 KB Output is correct
32 Correct 16 ms 5752 KB Output is correct
33 Correct 7 ms 5024 KB Output is correct
34 Correct 16 ms 5968 KB Output is correct
35 Correct 10 ms 5916 KB Output is correct
36 Correct 25 ms 6008 KB Output is correct
37 Correct 11 ms 5808 KB Output is correct
38 Correct 13 ms 5752 KB Output is correct
39 Correct 21 ms 5992 KB Output is correct
40 Partially correct 72 ms 5928 KB Partially correct - number of queries: 6933
41 Correct 34 ms 6004 KB Output is correct
42 Correct 42 ms 5872 KB Output is correct
43 Correct 43 ms 5880 KB Output is correct
44 Correct 34 ms 5900 KB Output is correct
45 Correct 28 ms 5848 KB Output is correct
46 Correct 11 ms 5800 KB Output is correct
47 Correct 35 ms 5984 KB Output is correct
48 Partially correct 57 ms 6012 KB Partially correct - number of queries: 5857
49 Correct 19 ms 5756 KB Output is correct
50 Partially correct 71 ms 6056 KB Partially correct - number of queries: 8002
51 Correct 24 ms 5968 KB Output is correct
52 Correct 11 ms 5752 KB Output is correct
53 Correct 11 ms 5916 KB Output is correct
54 Correct 24 ms 5912 KB Output is correct
55 Correct 14 ms 5804 KB Output is correct
56 Partially correct 50 ms 6120 KB Partially correct - number of queries: 7970
57 Partially correct 50 ms 5900 KB Partially correct - number of queries: 5731
58 Partially correct 57 ms 6024 KB Partially correct - number of queries: 5833
59 Correct 28 ms 5972 KB Output is correct
60 Correct 41 ms 5896 KB Output is correct
61 Correct 14 ms 5800 KB Output is correct
62 Correct 14 ms 6008 KB Output is correct
63 Correct 11 ms 5924 KB Output is correct
64 Correct 14 ms 5752 KB Output is correct
65 Correct 9 ms 5908 KB Output is correct
66 Correct 12 ms 5800 KB Output is correct
67 Correct 17 ms 5780 KB Output is correct
68 Correct 12 ms 5752 KB Output is correct
69 Correct 9 ms 5900 KB Output is correct
70 Correct 10 ms 5920 KB Output is correct
71 Partially correct 46 ms 6092 KB Partially correct - number of queries: 9075
72 Correct 13 ms 5836 KB Output is correct
73 Partially correct 73 ms 5952 KB Partially correct - number of queries: 8963
74 Partially correct 79 ms 6148 KB Partially correct - number of queries: 9011
75 Correct 12 ms 5760 KB Output is correct
76 Partially correct 47 ms 6096 KB Partially correct - number of queries: 7923
77 Partially correct 69 ms 6056 KB Partially correct - number of queries: 8197
78 Correct 19 ms 5868 KB Output is correct
79 Correct 50 ms 5848 KB Output is correct
80 Partially correct 75 ms 6056 KB Partially correct - number of queries: 8272
81 Partially correct 39 ms 6076 KB Partially correct - number of queries: 8284
82 Partially correct 96 ms 6084 KB Partially correct - number of queries: 8229
83 Correct 13 ms 5808 KB Output is correct
84 Partially correct 62 ms 6040 KB Partially correct - number of queries: 6849
85 Partially correct 86 ms 6008 KB Partially correct - number of queries: 8247
86 Correct 16 ms 5760 KB Output is correct
87 Correct 12 ms 5760 KB Output is correct
88 Correct 14 ms 5804 KB Output is correct
89 Correct 14 ms 5888 KB Output is correct
90 Correct 11 ms 5804 KB Output is correct
91 Correct 13 ms 5760 KB Output is correct
92 Correct 12 ms 5760 KB Output is correct
93 Correct 15 ms 5760 KB Output is correct
94 Correct 18 ms 5760 KB Output is correct
95 Correct 17 ms 5888 KB Output is correct
96 Correct 12 ms 5888 KB Output is correct
97 Correct 9 ms 5896 KB Output is correct