답안 #903608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
903608 2024-01-11T10:08:49 Z JakobZorz 커다란 상품 (IOI17_prize) C++17
97.71 / 100
29 ms 3040 KB
#include"prize.h"
#include<iostream>
#include<vector>
#include<set>
using namespace std;

bool dpt[200000];
pair<int,int>dp[200000];
int n;
bool found;

void query(int i){
    if(dpt[i])
        return;
    dpt[i]=true;
    auto res=ask(i);
    dp[i]={res[0],res[1]};
    if(res[0]+res[1]==0){
        found=true;
        return;
    }
    int c=i+1;
    while(c<n){
        if(dpt[c]){
            if(dp[c]==dp[i]){
                for(int j=i+1;j<c;j++){
                    dp[j]=dp[i];
                    dpt[j]=true;
                }
            }
            break;
        }
        c++;
    }
    
    c=i-1;
    while(c>=0){
        if(dpt[c]){
            if(dp[c]==dp[i]){
                for(int j=c+1;j<i;j++){
                    dp[j]=dp[i];
                    dpt[j]=true;
                }
            }
            break;
        }
        c--;
    }
}

void fo(int l,int r){
    if(l>=r)
        return;
    int m=(l+r)/2;
    if(found)
        return;
    query(m);
    
    if(l<r-1){
        if(dp[m].first>dp[m].second){
            fo(l,m);
            fo(m,r);
        }else{
            fo(m,r);
            fo(l,m);
        }
    }
}

int find_best(int N){
    n=N;
    fo(0,n);
    
    for(int i=0;i<n;i++)
        if(dpt[i]&&dp[i].first+dp[i].second==0)
            return i;
    
	return -1;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:74:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   74 |     for(int i=0;i<n;i++)
      |     ^~~
prize.cpp:78:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   78 |  return -1;
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 960 KB Output is correct
2 Correct 1 ms 708 KB Output is correct
3 Correct 1 ms 708 KB Output is correct
4 Correct 1 ms 1476 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
6 Correct 1 ms 1220 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 1 ms 712 KB Output is correct
10 Correct 1 ms 1316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 964 KB Output is correct
2 Correct 1 ms 708 KB Output is correct
3 Correct 1 ms 708 KB Output is correct
4 Correct 1 ms 1228 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 1 ms 1320 KB Output is correct
11 Correct 3 ms 1580 KB Output is correct
12 Correct 5 ms 2544 KB Output is correct
13 Correct 3 ms 1328 KB Output is correct
14 Correct 5 ms 964 KB Output is correct
15 Correct 9 ms 928 KB Output is correct
16 Correct 9 ms 1940 KB Output is correct
17 Partially correct 27 ms 2360 KB Partially correct - number of queries: 5091
18 Correct 12 ms 1328 KB Output is correct
19 Correct 27 ms 2372 KB Output is correct
20 Correct 12 ms 1628 KB Output is correct
21 Correct 5 ms 708 KB Output is correct
22 Correct 10 ms 1684 KB Output is correct
23 Correct 5 ms 2172 KB Output is correct
24 Correct 3 ms 1428 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 1 ms 744 KB Output is correct
27 Correct 2 ms 676 KB Output is correct
28 Correct 10 ms 1688 KB Output is correct
29 Correct 7 ms 1216 KB Output is correct
30 Correct 16 ms 1564 KB Output is correct
31 Partially correct 27 ms 2252 KB Partially correct - number of queries: 5034
32 Correct 2 ms 736 KB Output is correct
33 Correct 0 ms 452 KB Output is correct
34 Correct 6 ms 1076 KB Output is correct
35 Correct 1 ms 924 KB Output is correct
36 Correct 9 ms 1064 KB Output is correct
37 Correct 5 ms 2100 KB Output is correct
38 Correct 5 ms 2180 KB Output is correct
39 Correct 15 ms 1876 KB Output is correct
40 Correct 12 ms 1392 KB Output is correct
41 Correct 3 ms 768 KB Output is correct
42 Correct 3 ms 760 KB Output is correct
43 Correct 1 ms 500 KB Output is correct
44 Correct 4 ms 900 KB Output is correct
45 Correct 6 ms 1104 KB Output is correct
46 Partially correct 27 ms 2300 KB Partially correct - number of queries: 5139
47 Correct 3 ms 1008 KB Output is correct
48 Correct 5 ms 1372 KB Output is correct
49 Correct 12 ms 1576 KB Output is correct
50 Correct 13 ms 2472 KB Output is correct
51 Correct 3 ms 652 KB Output is correct
52 Partially correct 25 ms 2568 KB Partially correct - number of queries: 5063
53 Correct 2 ms 1224 KB Output is correct
54 Correct 4 ms 764 KB Output is correct
55 Partially correct 26 ms 2664 KB Partially correct - number of queries: 5092
56 Correct 13 ms 1724 KB Output is correct
57 Correct 19 ms 1888 KB Output is correct
58 Correct 18 ms 2108 KB Output is correct
59 Correct 2 ms 800 KB Output is correct
60 Correct 1 ms 504 KB Output is correct
61 Correct 3 ms 1152 KB Output is correct
62 Correct 4 ms 2428 KB Output is correct
63 Correct 2 ms 1152 KB Output is correct
64 Correct 1 ms 452 KB Output is correct
65 Correct 5 ms 1984 KB Output is correct
66 Correct 2 ms 1220 KB Output is correct
67 Correct 1 ms 1224 KB Output is correct
68 Correct 1 ms 1216 KB Output is correct
69 Correct 1 ms 1476 KB Output is correct
70 Correct 1 ms 1216 KB Output is correct
71 Correct 29 ms 2772 KB Output is correct
72 Correct 6 ms 2664 KB Output is correct
73 Correct 26 ms 2612 KB Output is correct
74 Correct 26 ms 3040 KB Output is correct
75 Correct 4 ms 2176 KB Output is correct
76 Correct 21 ms 2812 KB Output is correct
77 Partially correct 28 ms 2820 KB Partially correct - number of queries: 5210
78 Correct 5 ms 2500 KB Output is correct
79 Correct 17 ms 2512 KB Output is correct
80 Partially correct 26 ms 2808 KB Partially correct - number of queries: 5212
81 Partially correct 27 ms 2384 KB Partially correct - number of queries: 5229
82 Partially correct 26 ms 2408 KB Partially correct - number of queries: 5192
83 Correct 4 ms 2240 KB Output is correct
84 Correct 25 ms 2460 KB Output is correct
85 Partially correct 27 ms 2428 KB Partially correct - number of queries: 5202
86 Correct 7 ms 2756 KB Output is correct
87 Correct 5 ms 2248 KB Output is correct
88 Correct 7 ms 2244 KB Output is correct
89 Correct 7 ms 2500 KB Output is correct
90 Correct 4 ms 2240 KB Output is correct
91 Correct 5 ms 2244 KB Output is correct
92 Correct 1 ms 1224 KB Output is correct
93 Correct 5 ms 2344 KB Output is correct
94 Correct 5 ms 2672 KB Output is correct
95 Correct 5 ms 2536 KB Output is correct
96 Correct 5 ms 2360 KB Output is correct
97 Correct 2 ms 1216 KB Output is correct