Submission #551628

#TimeUsernameProblemLanguageResultExecution timeMemory
551628hoanghq2004Scales (IOI15_scales)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "scales.h" using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 gen(std :: chrono :: system_clock :: now().time_since_epoch().count()); // //int getHeaviest() { // //} //int getLightest() { // //} //int getMedian() { // //} //int getNextLightest() { // //} set <vector <int> > cands; void init(int T) { srand(time(nullptr)); vector <int> p; for (int i = 0; i < 6; ++i) p.push_back(i); do { cands.insert(p); } while (next_permutation(p.begin(), p.end())); } struct query { int a, b, c, d, type; }; vector <query> Q; #define max(a, b, c) max({a, b, c}) #define min(a, b, c) min({a, b, c}) void orderCoins() { while (1) { if (cands.size() == 1) { int W[6]; for (int i = 0; i < 6; ++i) W[i] = (*cands.begin())[i] + 1; answer(W); } Q.clear(); int cur = 1e9; for (int a = 0; a < 6; ++a) for (int b = a + 1; b < 6; ++b) for (int c = b + 1; c < 6; ++c) { // type 0 int cnt_a = 0, cnt_b = 0, cnt_c = 0; for (auto p: cands) { if (max(p[a], p[b], p[c]) == p[a]) ++cnt_a; if (max(p[a], p[b], p[c]) == p[b]) ++cnt_b; if (max(p[a], p[b], p[c]) == p[c]) ++cnt_c; } if (max(cnt_a, cnt_b, cnt_c) < cur) { cur = max(cnt_a, cnt_b, cnt_c); Q = {{a, b, c, 0, 0}}; } else if (max(cnt_a, cnt_b, cnt_c) == cur) Q.push_back({a, b, c, 0, 0}); // type 1 int cnt_a = 0, cnt_b = 0, cnt_c = 0; for (auto p: cands) { if (min(p[a], p[b], p[c]) == p[a]) ++cnt_a; if (min(p[a], p[b], p[c]) == p[b]) ++cnt_b; if (min(p[a], p[b], p[c]) == p[c]) ++cnt_c; } if (max(cnt_a, cnt_b, cnt_c) < cur) { cur = max(cnt_a, cnt_b, cnt_c); Q = {{a, b, c, 0, 1}}; } else if (max(cnt_a, cnt_b, cnt_c) == cur) Q.push_back({a, b, c, 0, 1}); // type 2 int cnt_a = 0, cnt_b = 0, cnt_c = 0; for (auto p: cands) { if (min(p[a], p[b], p[c]) != p[a] && max(p[a], p[b], p[c]) != p[a]) ++cnt_a; if (min(p[a], p[b], p[c]) != p[b] && max(p[a], p[b], p[c]) != p[b]) ++cnt_b; if (min(p[a], p[b], p[c]) != p[c] && max(p[a], p[b], p[c]) != p[c]) ++cnt_c; } if (max(cnt_a, cnt_b, cnt_c) < cur) { cur = max(cnt_a, cnt_b, cnt_c); Q = {{a, b, c, 0, 2}}; } else if (max(cnt_a, cnt_b, cnt_c) == cur) Q.push_back({a, b, c, 0, 2}); // type 3 for (int d = 0; d < 6; ++d) { if (d == a || d == b || d == c) continue; for (auto p: cands) { int x = -1; if (p[a] > p[d] && (x == -1 || p[a] < p[x])) x = a; if (p[b] > p[d] && (x == -1 || p[b] < p[x])) x = b; if (p[c] > p[d] && (x == -1 || p[c] < p[x])) x = c; if (x == -1) { x = a; if (p[b] < p[x]) x = b; if (p[c] < p[x]) x = c; } if (x == a) ++cnt_a; if (x == b) ++cnt_b; if (x == c) ++cnt_c; } } if (max(cnt_a, cnt_b, cnt_c) < cur) { cur = max(cnt_a, cnt_b, cnt_c); Q = {{a, b, c, d, 3}}; } else if (max(cnt_a, cnt_b, cnt_c) == cur) Q.push_back({a, b, c, d, 3}); } query [a, b, c, d, type] = Q[rand() % Q.size()]; set <vector <int> > ncands; if (type == 0) { int x = getHeaviest(a, b, c); for (auto p: cands) if (max(p[a], p[b], p[c]) == p[x]) ncands.insert(p); } else if (type == 1) { int x = getLightest(a, b, c); for (auto p: cands) if (min(p[a], p[b], p[c]) == p[x]) ncands.insert(p); } else if (type == 2) { int x = getMedian(a, b, c); for (auto p: cands) if (max(p[a], p[b], p[c]) != p[x] && min(p[a], p[b], p[c]) != p[x]) ncands.insert(p); } else { int x = getNextLightest(a, b, c, d); for (auto p: cands) { int y = -1; if (p[a] > p[d] && (y == -1 || p[a] < p[y])) y = a; if (p[b] > p[d] && (y == -1 || p[b] < p[y])) y = b; if (p[c] > p[d] && (y == -1 || p[c] < p[y])) y = c; if (y == -1) { y = a; if (p[b] < p[y]) y = b; if (p[c] < p[y]) y = c; } if (y == a) ++cnt_a; if (y == b) ++cnt_b; if (y == c) ++cnt_c; if (x == y) ncands.insert(p); } } swap(cands, ncands); } } //int main() { // ios :: sync_with_stdio(0); cin.tie(0); // //}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:32:15: warning: conversion from 'time_t' {aka 'long int'} to 'unsigned int' may change value [-Wconversion]
   32 |     srand(time(nullptr));
      |           ~~~~^~~~~~~~~
scales.cpp:31:15: warning: unused parameter 'T' [-Wunused-parameter]
   31 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:73:25: error: redeclaration of 'int cnt_a'
   73 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                         ^~~~~
scales.cpp:62:25: note: 'int cnt_a' previously declared here
   62 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                         ^~~~~
scales.cpp:73:36: error: redeclaration of 'int cnt_b'
   73 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                    ^~~~~
scales.cpp:62:36: note: 'int cnt_b' previously declared here
   62 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                    ^~~~~
scales.cpp:73:47: error: redeclaration of 'int cnt_c'
   73 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                               ^~~~~
scales.cpp:62:47: note: 'int cnt_c' previously declared here
   62 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                               ^~~~~
scales.cpp:84:25: error: redeclaration of 'int cnt_a'
   84 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                         ^~~~~
scales.cpp:62:25: note: 'int cnt_a' previously declared here
   62 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                         ^~~~~
scales.cpp:84:36: error: redeclaration of 'int cnt_b'
   84 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                    ^~~~~
scales.cpp:62:36: note: 'int cnt_b' previously declared here
   62 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                    ^~~~~
scales.cpp:84:47: error: redeclaration of 'int cnt_c'
   84 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                               ^~~~~
scales.cpp:62:47: note: 'int cnt_c' previously declared here
   62 |                     int cnt_a = 0, cnt_b = 0, cnt_c = 0;
      |                                               ^~~~~
scales.cpp:114:40: error: 'd' was not declared in this scope
  114 |                         Q = {{a, b, c, d, 3}};
      |                                        ^
scales.cpp:114:45: error: no match for 'operator=' (operand types are 'std::vector<query>' and '<brace-enclosed initializer list>')
  114 |                         Q = {{a, b, c, d, 3}};
      |                                             ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from scales.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = query; _Alloc = std::allocator<query>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<query>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from scales.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = query; _Alloc = std::allocator<query>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<query>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = query; _Alloc = std::allocator<query>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<query>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:115:87: error: 'd' was not declared in this scope
  115 |                     } else if (max(cnt_a, cnt_b, cnt_c) == cur) Q.push_back({a, b, c, d, 3});
      |                                                                                       ^
scales.cpp:115:92: error: no matching function for call to 'std::vector<query>::push_back(<brace-enclosed initializer list>)'
  115 |                     } else if (max(cnt_a, cnt_b, cnt_c) == cur) Q.push_back({a, b, c, d, 3});
      |                                                                                            ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from scales.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = query; _Alloc = std::allocator<query>; std::vector<_Tp, _Alloc>::value_type = query]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const query&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = query; _Alloc = std::allocator<query>; std::vector<_Tp, _Alloc>::value_type = query]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<query>::value_type&&' {aka 'query&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
scales.cpp:117:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  117 |         query [a, b, c, d, type] = Q[rand() % Q.size()];
      |               ^
scales.cpp:117:15: error: structured binding declaration cannot have type 'query'
  117 |         query [a, b, c, d, type] = Q[rand() % Q.size()];
      |               ^~~~~~~~~~~~~~~~~~
scales.cpp:117:15: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
scales.cpp:143:31: error: 'cnt_a' was not declared in this scope
  143 |                 if (y == a) ++cnt_a;
      |                               ^~~~~
scales.cpp:144:31: error: 'cnt_b' was not declared in this scope
  144 |                 if (y == b) ++cnt_b;
      |                               ^~~~~
scales.cpp:145:31: error: 'cnt_c' was not declared in this scope
  145 |                 if (y == c) ++cnt_c;
      |                               ^~~~~