제출 #1363001

#제출 시각아이디문제언어결과실행 시간메모리
1363001avahw앵무새 (IOI11_parrots)C++20
24 / 100
5 ms836 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

string convert(int num){
  string s = "";
  for(int j = 7; j >= 0; j--){
    if(num >= pow(2, j)){
      num -= pow(2, j);
      s += '1';
    }
    else s += '0';
  }
  return s;
}

void encode(int N, int M[])
{
  int n = N;
  // break each number into 8-byte strings
  string all_nums;
  for(int i = 0; i < n; i++) all_nums += convert(M[i]);
  for(int i = 0; i < all_nums.size() - 1; i += 2){
    int val = 0;
    if(all_nums[i] == '1') val += 1;
    if(all_nums[i + 1] == '1') val += 2;
    for(int j = 0; j < val; j++){
      send((i / 2));
    } 
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;

int convert(string& s, int l, int r){
  int res = 0;
  string thing ="";
  for(int i = r; i >= l; i--) thing += s[i];
  for(int i = 0; i <= 7; i++){
    if(thing[i] == '1') res += pow(2, (i));
  }
  return res;
}

void decode(int N, int L, int X[])
{
  int n = N;
  vector<string> ref = {"00", "10", "01", "11"};
  map<int, int> freq;
  for(int i = 0; i < L; i++){
    freq[X[i]]++;
  }
  string s;
  for(int i = 0; i < N; i++){
    s += "00000000";
  }
  for(auto e : freq){
    int ind = e.first * 2;
    string replace = ref[e.second];
    s[ind] = replace[0];
    s[ind + 1] = replace[1];
  }
  // convert back to decimal
  for(int i = 0; i < n; i++){
    int num = convert(s, i * 8, (i + 1) * 8 - 1);
    output(num);
  }
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…