This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void solve(int k, int i){
int zero = 0, one = 0;
vector<int> bit(8, 0);
for(int i=0; i<8; i++){
if(k & (1 << i)){
one ++;
bit[i] = 1;
} else zero ++;
}
// 0: 0 e 1, 1: 2 e 3, 2: 4 e 5
vector<int> pair;
for(int j=0; j<8; j+=2){
if(!bit[j] && !bit[j + 1]) pair.push_back(0);
if(!bit[j] && bit[j + 1]) pair.push_back(1);
if(bit[j] && !bit[j + 1]) pair.push_back(2);
if(bit[j] && bit[j + 1]) pair.push_back(3);
}
for(int j=0; j<pair[0]; j++){
send(i * (1 << 2) + 0);
// cout << i * (1 << 2) + 0 << " ";
}
// cout << ", ";
for(int j=0; j<pair[1]; j++){
send(i * (1 << 2) + 1);
// cout << i * (1 << 2) + 1 << " ";
}
// cout << ", ";
for(int j=0; j<pair[2]; j++){
send(i * (1 << 2) + 2);
// cout << i * (1 << 2) + 2 << " ";
}
for(int j=0; j<pair[3]; j++){
send(i * (1 << 2) + 3);
// cout << i * (1 << 2) + 3 << " ";
}
}
void encode(int n, int m[]){
for(int i=0; i<n; i++){
solve(m[i], i);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int l, int x[]){
vector<vector<int>> id(n);
for(int i=0; i<l; i++){
id[x[i] >> 2].push_back(x[i] % 4);
}
for(int i=0; i<n; i++){
vector<int> pair(4, 0);
for(auto k : id[i]){
pair[k] ++;
}
int ans = 0;
for(int j=0; j<4; j++){
if(pair[j] == 1) ans += (1 << (2 * j + 1));
if(pair[j] == 2) ans += (1 << (2 * j));
if(pair[j] == 3) ans += (1 << (2 * j)) + (1 << (2 * j + 1));
}
output(ans);
}
}
# | 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... |