Submission #1338107

#TimeUsernameProblemLanguageResultExecution timeMemory
1338107hyyh앵무새 (IOI11_parrots)C++20
Compilation error
0 ms0 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <set> 
#include <bitset>
using namespace std;
using pii = pair<int,int>;
#define s second
#define f first

void encode(int N, int M[])
{
  bitset<512> bs;
  int cnt = 0;
  for(int i{};i < N;i++){
    for(int j{};j < 8;j++){
      bs[i*8+j] = (M[i]>>j)&1;
      cnt += bs[i*8+j];
    }
  }
  int save = 0;
  if(cnt > N*4){
    send(0);
    send(0);
    send(0);
    send(0);
    save = 1;
  }
  for(int i{};i < N*8;i++){
    if(bs[i] ^ save){
      if(i >= 256){
        send(i-256);
        send(i-256);
      }
      else send(i);
    }
  }
}

//2 bit position 1-4 -> 6 bit position
#include "decoder.h"
#include "decoderlib.h"
#include <bitset>
#include <iostream>
#include <map>

void decode(int N, int L, int X[])
{
  std::bitset<512> ans;
  map<int,int> mp;
  for(int i{};i < L;i++){
    if(!mp.count(X[i])) mp[X[i]] = 0;
    mp[X[i]]++;
  }
  int val = 1;
  if(!mp.count(0)) mp[0] = 0;
  int cnt = mp[0];
  if(cnt >= 4){
    val = 0;
    ans.set();
    cnt = 4;
  }
  else cnt = 0;
  mp[0] -= cnt;
  for(auto [a,b]:mp){
    if(b == 1 || b == 3){
      ans[a] = val;
    }
    if(b == 2 || b == 3){
      ans[a+256] = val;
    }
  }
  //cout << ans << endl;
  int cur = 0;
  for(int i{};i <= N*8;i++){
    if(i%8 == 0 && i != 0) output(cur),cur = 0;
    cur += ans[i]<<(i%8);
    //cout << cur << " -"<< endl;
  }
}

Compilation message (stderr)

# 2번째 컴파일 단계

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:10:3: error: 'map' was not declared in this scope
   10 |   map<int,int> mp;
      |   ^~~
decoder.cpp:10:3: note: suggested alternatives:
In file included from /usr/include/c++/13/map:63,
                 from decoder.cpp:5:
/usr/include/c++/13/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/13/map:80:13: note:   'std::pmr::map'
   80 |       using map
      |             ^~~
decoder.cpp:10:7: error: expected primary-expression before 'int'
   10 |   map<int,int> mp;
      |       ^~~
decoder.cpp:12:9: error: 'mp' was not declared in this scope
   12 |     if(!mp.count(X[i])) mp[X[i]] = 0;
      |         ^~
decoder.cpp:13:5: error: 'mp' was not declared in this scope
   13 |     mp[X[i]]++;
      |     ^~
decoder.cpp:16:7: error: 'mp' was not declared in this scope
   16 |   if(!mp.count(0)) mp[0] = 0;
      |       ^~
decoder.cpp:17:13: error: 'mp' was not declared in this scope
   17 |   int cnt = mp[0];
      |             ^~