Submission #1339848

#TimeUsernameProblemLanguageResultExecution timeMemory
1339848Desh03Message (IOI24_message)C++20
Compilation error
0 ms0 KiB
#include "message.h"
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());

void send_message(vector<bool> M, vector<bool> C) {
    vector<bool> xd = {1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1};
    for (int i = 0; i < xd.size(); i++) {
        vector<bool> p(31);
        for (int j = 0; j < 31; j++) {
            if (C[j]) {
                p[j] = (rng() & 1);
            } else {
                p[j] = xd[i];
            }
        }
        send_packet(p);
    }
    int S = M.size();
    vector<bool> p(31);
    for (int j = 0, k = 0; j < 31; j++) {
        if (C[j]) {
            p[j] = (rng() & 1);
        } else {
            p[j] = (S >> k & 1);
            k++;
        }
    }
    for (int i = 0, k = 0; i < (S + 15) / 16; i++) {
        vector<bool> p(31);
        for (int j = 0; j < 31; j++) {
            if (C[j]) {
                p[j] = (rng() & 1);
            } else if (k < S) {
                p[j] = M[k++];
            }
        }
        send_packet(p);
    }
}

vector<bool> receive_message(vector<vector<bool>> R) {
    vector<bool> xd = {1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1};
    vector<bool> C(31, 1);
    for (int i = 0; i < xd.size(); i++) {
        for (int j = 0; j < 31; j++) {
            if (xd[i]) {
                C[j] &= R[i][j];
            } else {
                C[j] &= !R[i][j];
            }
        }
    }
    int i = xd.size(), S = 0;
    for (int j = 0, k = 0; j < 31; j++) {
        if (C[j]) {
            S |= (1 << k) * R[i][j];
            k++;
        }
    }
    i++;
    vector<bool> ans(S);
    for (int t = 0, k = 0; t < (S + 15) / 16; t++, i++) {
        for (int j = 0; j < 31 && k < S; j++) {
            if (C[j]) {
                ans[k++] = R[i][j];
            }
        }
    }
    return ans;
}

Compilation message (stderr)

message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:50:22: error: no match for 'operator&=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
   50 |                 C[j] &= R[i][j];
      |                 ~~~~~^~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:176,
                 from message.cpp:2:
/usr/include/c++/13/future:176:18: note: candidate: 'std::launch& std::operator&=(launch&, launch)'
  176 |   inline launch& operator&=(launch& __x, launch __y) noexcept
      |                  ^~~~~~~~
/usr/include/c++/13/future:176:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::launch&'
  176 |   inline launch& operator&=(launch& __x, launch __y) noexcept
      |                             ~~~~~~~~^~~
In file included from /usr/include/c++/13/format:39,
                 from /usr/include/c++/13/bits/chrono_io.h:39,
                 from /usr/include/c++/13/chrono:3370,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:172:
/usr/include/c++/13/charconv:661:3: note: candidate: 'constexpr std::chars_format& std::operator&=(chars_format&, chars_format)'
  661 |   operator&=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/charconv:661:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::chars_format&'
  661 |   operator&=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/13/streambuf:43,
                 from /usr/include/c++/13/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54:
/usr/include/c++/13/bits/ios_base.h:186:3: note: candidate: 'const std::_Ios_Iostate& std::operator&=(_Ios_Iostate&, _Ios_Iostate)'
  186 |   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:186:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  186 |   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:146:3: note: candidate: 'const std::_Ios_Openmode& std::operator&=(_Ios_Openmode&, _Ios_Openmode)'
  146 |   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:146:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  146 |   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:103:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator&=(_Ios_Fmtflags&, _Ios_Fmtflags)'
  103 |   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:103:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
  103 |   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/13/bits/memory_resource.h:38,
                 from /usr/include/c++/13/vector:80,
                 from message.h:1,
                 from message.cpp:1:
/usr/include/c++/13/cstddef:172:3: note: candidate: 'constexpr std::byte& std::operator&=(byte&, byte)'
  172 |   operator&=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/cstddef:172:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  172 |   operator&=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
message.cpp:52:22: error: no match for 'operator&=' (operand types are 'std::vector<bool>::reference' and 'bool')
   52 |                 C[j] &= !R[i][j];
      |                 ~~~~~^~~~~~~~~~~
/usr/include/c++/13/future:176:18: note: candidate: 'std::launch& std::operator&=(launch&, launch)'
  176 |   inline launch& operator&=(launch& __x, launch __y) noexcept
      |                  ^~~~~~~~
/usr/include/c++/13/future:176:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::launch&'
  176 |   inline launch& operator&=(launch& __x, launch __y) noexcept
      |                             ~~~~~~~~^~~
/usr/include/c++/13/charconv:661:3: note: candidate: 'constexpr std::chars_format& std::operator&=(chars_format&, chars_format)'
  661 |   operator&=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/charconv:661:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::chars_format&'
  661 |   operator&=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/13/bits/ios_base.h:186:3: note: candidate: 'const std::_Ios_Iostate& std::operator&=(_Ios_Iostate&, _Ios_Iostate)'
  186 |   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:186:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  186 |   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:146:3: note: candidate: 'const std::_Ios_Openmode& std::operator&=(_Ios_Openmode&, _Ios_Openmode)'
  146 |   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:146:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  146 |   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:103:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator&=(_Ios_Fmtflags&, _Ios_Fmtflags)'
  103 |   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:103:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
  103 |   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/cstddef:172:3: note: candidate: 'constexpr std::byte& std::operator&=(byte&, byte)'
  172 |   operator&=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/cstddef:172:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  172 |   operator&=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~