이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int)x.size()
void encode(int n, int x[]){
vector<int> ans;
int xx = 0;
for(int i=0;i<8;i++){
int cnt = 0;
for(int j=0;j<n;j++){
if(x[j] >> i & 1) cnt++;
}
if(cnt * 2 >= n) xx += (1<<i);
}
//cout<<xx<<"\n";
for(int i=0;i<n;i++){
x[i] ^= xx;
for(int j=0;j<8;j+=2){
int f = j, s = j+1;
if(x[i] >> f & 1) ans.pb((i << 2) + j/2);
if(x[i] >> s & 1){
ans.pb((i << 2) + j/2);
ans.pb((i << 2) + j/2);
}
}
}
for(int i=0;i<sz(ans);i++){
send(ans[i]);
}
for(int i=0;i<4;i++) send(xx);
}
#include "decoder.h"
#include "decoderlib.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int l, int ans[]){
map<int, int> mm;
for(int i=0;i<l;i++) mm[ans[i]]++;
int xx = 0;
for(int i=0;i<l;i++){
if(mm[ans[i]] >= 4){
mm[ans[i]] -= 4;
xx = ans[i];
break;
}
}
//cout<<"_____________\n";
//cout<<xx<<"\n";
//for(int i=0;i<l;i++){
//for(int j=0;j<8;j++){
//cout<<(ans[i] >> j & 1);
//}cout<<"\n";
//}cout<<"\n";
vector<int> res(n);
for(int i=0;i<n;i++){
for(int j=0;j<8;j+=2){
int gr = j/2;
res[i] += mm[(i << 2) + gr]*(1 << j);
}
}
//for(int i=0;i<n;i++) cout<<(res[i] ^ xx)<<" ";
//cout<<"\n";
for(int i=0;i<n;i++){
output(res[i] ^ xx);
}
}
# | 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... |