제출 #598442

#제출 시각아이디문제언어결과실행 시간메모리
598442MohamedFaresNebili커다란 상품 (IOI17_prize)C++14
90 / 100
80 ms1864 KiB
#include <bits/stdc++.h>
#include "prize.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
 
                using namespace std;
 
                using ll = long long;
                using ld = long double;
                using ii = pair<ll, ll>;
                using vi = vector<int>;
 
                #define ff first
                #define ss second
                #define pb push_back
                #define all(x) (x).begin(), (x).end()
                #define lb lower_bound
 
                const int MOD = 1e9 + 7;
 
                int A[200005][2];
                vector<int> query(int k) {
                    if(A[k][0] != -1)
                        return {A[k][0], A[k][1]};
                  	vector<int> V = ask(k);
                  	A[k][0] = V[0];
                  	A[k][1] = V[1];
                    return V;
                }
 
                int find_best(int N) {
                    memset(A, -1, sizeof A);
                    int curr = 0;
                    for(int l = 0; l < min(N, 474); l++) {
                        vector<int> V = query(l);
                        curr = max(curr, V[0] + V[1]);
                    }
                    int i = 0;
                    while(i < N) {
                        vector<int> V = query(i);
                        if(V[0] + V[1] == 0) return i;
                        if(V[0] + V[1] != curr) {
                            i++; continue;
                        }
                        int l = i, r = N - 1, nxt = i;
                        while(l <= r) {
                            int md = (l + r + 1) / 2;
                            vector<int> U = query(md);
                            if(U[0] == V[0] && U[1] == V[1])
                                nxt = md, l = md + 1;
                            else r = md - 1;
                        }
                        i = nxt + 1;
                    }
                }

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'std::vector<int> query(int)':
prize.cpp:24:21: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |                     if(A[k][0] != -1)
      |                     ^~
prize.cpp:26:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   26 |                    vector<int> V = ask(k);
      |                    ^~~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:56:17: warning: control reaches end of non-void function [-Wreturn-type]
   56 |                 }
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...