답안 #963769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963769 2024-04-15T15:56:38 Z Amr 앵무새 (IOI11_parrots) C++17
0 / 100
1 ms 1556 KB
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz size()
void encode(int N, int M[])
{
    vector<pair<ll,ll> > v;
    for(int i = 0; i < N; i++) v.push_back({M[i],i});
    sort(v.begin(),v.end());
    for(int i = 0; i < N; i++)
    {
        send(M[i]);
        send(M[i]);
        send(M[i]);
        send(M[i]);
    }
    for(int i = 0; i < N; i++)
    {


        //cout << v[i].second << " ";
        ll j = i/2;
        if(v[i].second>=16&&i%2)
        {send(v[i].second%16+j*16);
        send(v[i].second%16+j*16);
        //send(v[i].second%16+j*16);
        send(v[i].second%16+j*16);}
        else if(v[i].second>=16)
        {send(v[i].second%16+j*16);
        //send(v[i].second%16+j*16);
        send(v[i].second%16+j*16);}
        else if(i%2)
        {send(v[i].second%16+j*16);
        //send(v[i].second%16+j*16);}
    }
    }



}

#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz size()
#define F first
#define S second
const int M = 256;
ll ans[M+2];
ll freq[M+2];
void decode(int N, int L, int X[])
{
    //for(int i = 0; i < L; i++) cout << X[i] << " "; cout << endl;
    //return;
    for(int i = 0; i < M; i++) freq[i] = 0;
    for(int i = 0; i < L; i++) freq[X[i]]++;
    vector<pair<ll,ll> > vv;
    vector<ll> v;
    for(int i = 0; i < M; i++){

    for(int j = 0 ; j < freq[i]/4; j++) v.push_back(i);
    if(freq[i]%4==0) vv.push_back({2*i,0});
    if(freq[i]%4==1) vv.push_back({2*i+1,0});
    if(freq[i]%4==2) vv.push_back({2*i,1});
    if(freq[i]%4==3) vv.push_back({2*i+1,1});








    }
  sort(vv.begin(),vv.end());
  //for(int i = 0; i < vv.sz; i++) cout << vv[i].F << " " << vv[i].S << endl;
 // cout << v.sz << " " << vv.sz << endl; return;
  ll l = 0;
  for(int i = 0; i < N; i++)
  {

      //cout << vv[l]%16 << " " << v[i]<< endl;
      ll l2 = l;
      if(vv[l].first&1)
      {
          if(i%2==0) l2++;
      }
      else{
        if(i%2==1) l2--;
      }
      ll y = vv[l2].second;
      ll x = vv[l2].F;
    x/=2;
    x%=16;
    //cout << x+y*16 << " ";
    ans[x+y*16] = v[i];

      l++;
  }

  for(int i=0; i< N; i++) {
    output(ans[i]);
  }

}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 780 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1300 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1300 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1556 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1312 KB Error : Output is wrong
2 Halted 0 ms 0 KB -