Submission #598477

#TimeUsernameProblemLanguageResultExecution timeMemory
598477MohamedFaresNebiliThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 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];
                int curr = 0, calc = 0, res = -1;
 
                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;
                }
                void solve(int l, int r) {
                  	if(res != -1) return;
                  	vector<int> V = ask(r);
                  	if(V[0] + V[1] == curr && V[0] == calc)
                      return;
                  	if(l == r) {
                      calc++;
                      if(V[0] + V[1] == 0) 
                        res = l;
                      return;
                    }
                  int md = (l + r) / 2;
                  	solve(l, md); solve(md + 1, r);
                }
				void init() {
                	queue<pair<int, int>> Q;
                  	Q.push({0, N - 1});
                  while(!Q.empty()) {
                    if(calc == 500) return;
                    int l = Q.front().ff, r = Q.front().ss; Q.pop();
                    if(A[r][0] == -1) {
                      query(r); calc++;
                    }
                    curr = max(curr, A[r][0] + A[r][1]);
                    if(l == r) continue;
                    int md = (l + r) / 2;
                    Q.push({l, md}); Q.push({md + 1, r});
                  }
                }
 
                int find_best(int N) {
                    memset(A, -1, sizeof A); 
                    init(); calc = 0;
                    solve(0, N - 1);
                    return res;
                }

Compilation message (stderr)

prize.cpp: In function 'std::vector<int> query(int)':
prize.cpp:26:21: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   26 |                     if(A[k][0] != -1)
      |                     ^~
prize.cpp:28:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |                    vector<int> V = ask(k);
      |                    ^~~~~~
prize.cpp: In function 'void init()':
prize.cpp:49:31: error: 'N' was not declared in this scope
   49 |                    Q.push({0, N - 1});
      |                               ^
prize.cpp:49:37: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   49 |                    Q.push({0, N - 1});
      |                                     ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~