제출 #1016856

#제출 시각아이디문제언어결과실행 시간메모리
1016856nisanduu앵무새 (IOI11_parrots)C++14
88 / 100
7 ms1776 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
 
void encode(int N, int M[])
{
  for(int i=0;i<min(N,32);i++){
      int st = i;
      int tmpst = 0;
      vector<int> bitss(8);
      for(int j=4;j>=0;j--){
          if(st&(1<<j)){
              bitss[3+j]=1;
          }
      }
      for(int k=0;k<=7;k++){
          if(bitss[k]){
            tmpst += (1<<k);
          }
      }
      for(int j=0;j<=7;j++){
          if(M[i]&(1<<j)){
              vector<int> tmp = bitss;
              for(int k=0;k<3;k++){
                  if((1<<k)&j){
                      tmp[k]=1;
                  }
              }
              int num = 0;
              for(int k=0;k<=7;k++){
                  if(tmp[k]==0) continue;
                  num += (1<<k);
              }
              send(num);
          }
      }
  }
  
  for(int i=32;i<min(N,64);i++){
      int st = i^32;
      int tmpst = 0;
      vector<int> bitss(8);
      for(int j=4;j>=0;j--){
          if(st&(1<<j)){
              bitss[3+j]=1;
          }
      }
      for(int k=0;k<=7;k++){
          if(bitss[k]){
            tmpst += (1<<k);
          }
      }
      for(int j=0;j<=7;j++){
          if(M[i]&(1<<j)){
              vector<int> tmp = bitss;
              for(int k=0;k<3;k++){
                  if((1<<k)&j){
                      tmp[k]=1;
                  }
              }
              int num = 0;
              for(int k=0;k<=7;k++){
                  if(tmp[k]==0) continue;
                  num += (1<<k);
              }
              send(num);
              send(num);
          }
      }
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[])
{
  
  vector<int> v(N+5);
  int lol = (1<<7) | (1<<6) | (1<<5) | (1<<4) | (1<<3);
  int l2 = 1 | (1<<1) | (1<<2);
  map<int,int> mp;
  for(int i=0;i<L;i++){
    mp[X[i]]++;
  }
  for(auto z:mp){
    if(z.second==1){
      int pos = (z.first&(lol))>>3;
      int bit = z.first&l2;
      int val = (1<<bit);
      v[pos] = v[pos] | val;
    }else if(z.second==2){
      int pos = (z.first&(lol))>>3;
      pos = pos | 32;
      int bit = z.first&l2;
      int val = (1<<bit);
      v[pos] = v[pos] | val;
    }else{
      int pos = (z.first&(lol))>>3;
      int bit = z.first&l2;
      int val = (1<<bit);
      v[pos] = v[pos] | val;

      pos = pos | 32;
      v[pos] = v[pos] | val;
    }
  }
  for(int i=0;i<N;i++) output(v[i]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...