Submission #1137647

#TimeUsernameProblemLanguageResultExecution timeMemory
1137647KaleemRazaSyedCOVID tests (CEOI24_covid)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count()); int n; double p; bool ask(vector<bool> mask) { assert(mask.size() == (size_t)n); std::string mask_str(n, ' '); for (int i = 0; i < n; i++) mask_str[i] = mask[i] ? '1' : '0'; printf("Q %s\n", mask_str.c_str()); fflush(stdout); char answer; scanf(" %c", &answer); return answer == 'P'; } vector<int> fig(vector<int> a) { if(a.empty()) return a; vector<bool> mask(n, false); vector<int> sol; for(int i : a) mask[i] = true; if(!ask(mask)) return sol; if(a.size() == 1) return a; vector<int> b; int c = min(a.size() - 1, a.size() * p + 1); for(int i = 0; i < a.size(); i++) { b.push_back(a[i]); if(b.size() == c || i + 1 == a.size()) { vector<int> solp = fig(b); for(int x : solp) sol.push_back(x); } } return sol; } vector<bool> solve() { vector<int> idx(n); iota(idx.begin(), idx.end(), 0); for(int i = 0; i < n; i ++) { int j = rnd() % (i + 1); swap(idx[i], idx[j]); } vector<bool> v(n, false); vector<int> sol = fig(idx); for(int i : sol) v[i] = true; return v; } int main() { int T; scanf("%d %lf %d", &n, &p, &T); for (int i = 0; i < T; i++) { vector<bool> answer = solve(); assert(answer.size() == (size_t)n); string answer_str(n, ' '); for (int j = 0; j < n; j++) answer_str[j] = answer[j] ? '1' : '0'; printf("A %s\n", answer_str.c_str()); fflush(stdout); char verdict; scanf(" %c", &verdict); if (verdict == 'W') exit(0); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'std::vector<int> fig(std::vector<int>)':
Main.cpp:40:14: error: no matching function for call to 'min(std::vector<int>::size_type, double)'
   40 |   int c = min(a.size() - 1, a.size() * p + 1);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:40:14: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'double')
   40 |   int c = min(a.size() - 1, a.size() * p + 1);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:40:14: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'double')
   40 |   int c = min(a.size() - 1, a.size() * p + 1);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
Main.cpp:40:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   40 |   int c = min(a.size() - 1, a.size() * p + 1);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
Main.cpp:40:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   40 |   int c = min(a.size() - 1, a.size() * p + 1);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'bool ask(std::vector<bool>)':
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf(" %c", &answer);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:76:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |   scanf("%d %lf %d", &n, &p, &T);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:91:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |     scanf(" %c", &verdict);
      |     ~~~~~^~~~~~~~~~~~~~~~~