Submission #1228858

#TimeUsernameProblemLanguageResultExecution timeMemory
1228858olnyfcxwpsMachine (IOI24_machine)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> #include <map> using namespace std; vector<int> answer(const vector<int> &q, int x) { vector<int> a; for (auto &t : q) t = t ^ x; sort(a.begin(), a.end()); return a; } vector<int> find_permutation(int n) { vector<int> q; for (int t = 0; t <= n + 2; t++) { if (t == 1 || t == 2 || t == 5) continue; q.push_back(t); } vector<int> a = use_machine(q); vector<int> a_sorted = a; sort(a_sorted.begin(), a_sorted.end()); int x = 0; for (; x <= 255; x++) { vector<int> b_sorted = answer(q, x); if (a_sorted == b_sorted) { break; } } for (auto &t : a) { a = a ^ x; } vector<int> final_answer(n); for (int i = 0; i < n; i++) { int j = q[i]; // find where j is in a int k = 0; for (; k < n && a[k] != j; k++) ; final_answer[k] = i; } return final_answer; }

Compilation message (stderr)

machine.cpp: In function 'std::vector<int> answer(const std::vector<int>&, int)':
machine.cpp:11:11: error: assignment of read-only reference 't'
   11 |         t = t ^ x;
      |         ~~^~~~~~~
machine.cpp: In function 'std::vector<int> find_permutation(int)':
machine.cpp:23:21: error: 'use_machine' was not declared in this scope
   23 |     vector<int> a = use_machine(q);
      |                     ^~~~~~~~~~~
machine.cpp:34:15: error: no match for 'operator^' (operand types are 'std::vector<int>' and 'int')
   34 |         a = a ^ x;
      |             ~ ^ ~
      |             |   |
      |             |   int
      |             std::vector<int>
In file included from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from machine.cpp:1:
/usr/include/c++/11/bits/ios_base.h:91:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator^(std::_Ios_Fmtflags, std::_Ios_Fmtflags)'
   91 |   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/11/bits/ios_base.h:91:27: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Ios_Fmtflags'
   91 |   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/ios_base.h:133:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator^(std::_Ios_Openmode, std::_Ios_Openmode)'
  133 |   operator^(_Ios_Openmode __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/11/bits/ios_base.h:133:27: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Ios_Openmode'
  133 |   operator^(_Ios_Openmode __a, _Ios_Openmode __b)
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/ios_base.h:173:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator^(std::_Ios_Iostate, std::_Ios_Iostate)'
  173 |   operator^(_Ios_Iostate __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/11/bits/ios_base.h:173:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Ios_Iostate'
  173 |   operator^(_Ios_Iostate __a, _Ios_Iostate __b)
      |             ~~~~~~~~~~~~~^~~