Submission #1297995

#TimeUsernameProblemLanguageResultExecution timeMemory
1297995bangchanMessage (IOI24_message)C++20
Compilation error
0 ms0 KiB
#include "message.h"
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;

#define F first
#define S second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define pb push_back
#define forn(i, x, n) for (ll i = x; i < ll(n); i++)
#define fornl(i, x, n) for(ll i = x; i >= ll(n); i--)
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define inf 10000000000000

void send_message(const vector<bool> M, vector<bool> C) {
  vb a(31, 0);
  vl idx; ll cl = 0;

  forn(i, 0, 31){
    forn(j, 0, 31) a[j] = C[j];
    if(!C[i]){i < 19 ? cl++; idx.pb(i);} 
    if(i < 19) send_packet(a);
  }

  if(cl > 4){
    ll h = 19, j = 0;
    while(h < 31){
      a.assign(31, 0);
      ll x = 0;
      for(ll i = 0; i < cl && h < 31; i++){
        if(C[h] == 0) x++;
        h++; a[idx[i]] = C[h];
      }
      cl += x; send_packet(a);
      j++;
    }
  }

  vb b(31, 0);
  forn(i, 0, 11){
    b[idx[i]] = (b.size() & (1 << i)) != 0;
  } send_packet(b);

  ll t = 0;
  for(ll i = 0; i < (M.size() + 15) / 16; i ++){ //+= 16
    ll p = 0;
    forn(j, 0, 16){p++; t++; a[idx[p]] = M[t];}
    send_packet(a);
  }
}

vector<bool> receive_message(vector<vector<bool>> R) {
  vb a; vl idx;
  forn(i, 0, 19){
    ll qo = 0, qn = 0;
    forn(j, 0, R[i].size()){ if(R[i][j]) qo++; else qn++;}
    if(qn > qo) idx.pb(i);
  }

  ll x = 19, act = idx.size();
  if(act > 4){
    ll h = 19;
    while(h < 31){
      act = idx.size();
      for(ll i = 0; i < act && h < 31; i++){
        if(!R[x][idx[i]]) idx.pb(h);
        h++;
      }
      x++;
    }
  } else {
    forn(j, 19, 31) idx.pb(j);
  }

  ll y = 0;
  forn(i, 0, 11) if(R[x][idx[i]]) y += (1 << i);
  x++;

  vb an(y);
  ll t = 0;
  for(ll i = 0; i < (y + 15) / 16; i++){ //+= 16
    ll p = 0;
    forn(j, 0, 16){p++; t++; an[j] = a[x][idx[p]];}
    x++;
  }

  return an;
}

Compilation message (stderr)

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:41:28: error: expected ':' before ';' token
   41 |     if(!C[i]){i < 19 ? cl++; idx.pb(i);}
      |                            ^
      |                            :
message.cpp:41:28: error: expected primary-expression before ';' token
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:103:42: error: no match for 'operator[]' (operand types are 'std::vector<bool>::reference' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
  103 |     forn(j, 0, 16){p++; t++; an[j] = a[x][idx[p]];}
      |                                          ^