제출 #1052563

#제출 시각아이디문제언어결과실행 시간메모리
1052563Piokemon앵무새 (IOI11_parrots)C++17
81 / 100
3 ms1752 KiB
#include "encoder.h"
#include "encoderlib.h"
using namespace std;

#include <bits/stdc++.h>
typedef __int128 ll;

void encode(int n, int m[]){
  ll ilosc[42][34];
  //     poz ter
  for (int x=0;x<=40;x++){
    for (int y=0;y<=32;y++)ilosc[x][y]=0;
  }
  ilosc[1][0]=1;
  for (int x=1;x<=40;x++){
    for (int y=0;y<=32;y++){
      ilosc[x][y+1]+=ilosc[x][y];
      ilosc[x+1][y]+=ilosc[x][y];
    }
  }
  vector<int> dupa;
  for (int blok=0;blok*8<n;blok++){
    int dlug=min(8,n-blok*8);
    ll wart=0;
    for (int x=0;x<dlug;x++){
      //cerr << (int)wart << ' ' << (int)wart*256 << ' ' << m[blok*8+x] << '\n';
      if (blok*8+x>=n)wart=wart*256;
      else wart=(wart*256)+(ll)m[blok*8+x];
    }
    
    int nr=0; //rang od blok*32 do (blok+1)*32-1;
    for (int x=0;x<dlug*5;x++){
      while (nr<32 && ilosc[dlug*5-x][32-nr]<=wart){
        wart-=ilosc[dlug*5-x][32-nr];
        nr++;
      }
      dupa.push_back(nr+blok*32);
    }
  }
  //for (int x:dupa) cerr << "send " << x << '\n';
  for (int x:dupa)send(x);
}
#include "decoder.h"
#include "decoderlib.h"
using namespace std;

#include <bits/stdc++.h>
typedef __int128 ll;

void decode(int n, int l, int x[])
{
  ll ilosc[42][34];
  //     poz ter
  for (int z=0;z<=40;z++){
    for (int y=0;y<=32;y++)ilosc[z][y]=0;
  }
  ilosc[1][0]=1;
  for (int z=1;z<=40;z++){
    for (int y=0;y<=32;y++){
      ilosc[z][y+1]+=ilosc[z][y];
      ilosc[z+1][y]+=ilosc[z][y];
    }
  }
  sort(x,x+l);
  vector<int> dupa2;
  for (int blok=0;blok*8<n;blok++){
    int dlug=min(8,n-blok*8);
    // bieremy papugi od blok*40 do blok*40+39
    ll wart=0;
    int nr=0;
    for (int y=0;y<5*dlug;y++){
      x[blok*40+y]-=blok*32;
      while(x[blok*40+y]>nr){
        wart+=ilosc[5*dlug-y][32-nr];
        nr++;
      }
    }
    /*cerr << "odeb ";
    vector<int> tempo;
    ll kop=wart;
    while(kop){
      tempo.push_back(kop%(ll)10);
      kop/=(ll)10;
    }
    for (int y=tempo.size()-1;y>=0;y--) cerr << tempo[y];
    cout << '\n';*/
    vector<int> temp;
    for (int y=0;y<dlug;y++){
      temp.push_back(wart%(ll)256);
      wart/=(ll)256;
    }
    for (int y=dlug-1;y>=0;y--)dupa2.push_back(temp[y]);
  }
  while(dupa2.size()>n)dupa2.pop_back();
  //for (int y:dupa2) cerr << "out " << y << '\n';
  for (int y:dupa2) output(y);
}

컴파일 시 표준 에러 (stderr) 메시지

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:52:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |   while(dupa2.size()>n)dupa2.pop_back();
      |         ~~~~~~~~~~~~^~
#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...