Submission #549188

#TimeUsernameProblemLanguageResultExecution timeMemory
549188esomerThe Big Prize (IOI17_prize)C++17
Compilation error
0 ms0 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; #define ll long long vector<int> v; vector<int> nw; int a[] = {475, 27, 5, 1}; ll mx; void bin(int l, int r, int lx, int rx){ if(v.size() == mx) return; if(l == r){ nw.push_back(v[l]); return; } int mid = (l + r) / 2; vector<int> rep = ask(v[mid]); // int curr = mid; while(rep[0] + rep[1] != mx && curr > l){ nw.push_back(v[curr]); curr--; rep = ask(v[curr]); // } if(rep[0] + rep[1] != mx) nw.push_back(v[curr]); if(lx + rep[1] < mx && l < curr) bin(l, curr - 1, lx, rep[1]); curr = mid; while(rep[0] + rep[1] != mx && curr < r){ nw.push_back(v[curr]); curr++; rep = ask(v[curr]); // } if(rep[0] + rep[1] != mx) nw.push_back(v[curr]); if(rx + rep[0] < mx && r > curr) bin(mid + 1, r, rep[0], rx); } int find_best(int n) { v.resize(n); for(int i = 0; i < n; i++){ v[i] = i; } int curr = 0; int t = 0; while(v.size() > 1 && t < 1){ mx = 0; map<int, int> mp; int lst = 0; for(int i = 0; i < a[curr] && i < v.size(); i++){ vector<int> rep = ask (v[i]); // mx = max(mx, rep[0] + rep[1]); mp[rep[0] + rep[1]]++; ll sum = mx * mx * mx * mx; lst = i + 1; if(rep[0] + rep[1] == 0) return v[i]; if(sum >= n) break; } int total = 0; for(auto p : mp){ if(p.first == mx) break; total += p.second; } bin(lst, v.size() - 1, total, 0); curr++; v = nw; sort(v.begin(), v.end()); nw.clear(); t++; } for(int x : v){ vector<int> rep = ask(x); if(rep[0] + rep[1] == 0) return x; } }

Compilation message (stderr)

prize.cpp: In function 'void bin(int, int, int, int)':
prize.cpp:14:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   14 |  if(v.size() == mx) return;
      |     ~~~~~~~~~^~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:50:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for(int i = 0; i < a[curr] && i < v.size(); i++){
      |                                 ~~^~~~~~~~~~
prize.cpp:52:32: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   52 |    mx = max(mx, rep[0] + rep[1]);
      |                                ^
In file included from /usr/include/c++/10/vector:60,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
prize.cpp:52:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   52 |    mx = max(mx, rep[0] + rep[1]);
      |                                ^
In file included from /usr/include/c++/10/vector:60,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
prize.cpp:52:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   52 |    mx = max(mx, rep[0] + rep[1]);
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
prize.cpp:52:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |    mx = max(mx, rep[0] + rep[1]);
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
prize.cpp:52:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |    mx = max(mx, rep[0] + rep[1]);
      |                                ^
prize.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^