이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
void encode(int N, int M[]){
vector <pii> v;
for(int i = 0; i < N; i++){
v.pb(mp(M[i], i));
}
sort(all(v));
for(int i = 0; i < N; i++){
int num = v[i].first, ind = v[i].second;
for(int bit = 4; bit < 8; bit++){
if(i&(1<<(bit-4))){
ind |= (1<<bit);
}
}
send(num); send(num); send(ind);
}
}
#include "decoder.h"
#include "decoderlib.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
void decode(int N, int L, int X[]){
vector <int> cnt(256), nums;
vector <pii> inds;
for(int i = 0; i < L; i++){
cnt[X[i]]++;
}
for(int i = 0; i < 256; i++){
while(cnt[i] > 1){
nums.pb(i);
cnt[i] -= 2;
}
if(cnt[i]){
int inc = 0, orig = 0;
for(int bit = 0; bit < 4; bit++){
if(i & (1<<bit)){
orig |= 1<<bit;
}
if(i & (1<<(bit+4))){
inc |= 1<<bit;
}
}
inds.pb(mp(inc, orig));
}
}
sort(all(nums));
sort(all(inds));
vector <pii> ans;
for(int i = 0; i < N; i++){
ans.pb(mp(inds[i].second, nums[i]));
}
sort(all(ans));
for(auto to : ans) output(to.second);
}
/*
8
0 0 1 1 0 0 1 0
6
1 255 13 26 49 216
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |