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;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
void encode(int n, int arr[])
{
for(int i=0;i<n;i++){
for(int j=0;j<8;j++){
vector<int>vt;
for(int k=0;k<4;k++){
if(i&(1<<k)){
vt.pb(1);
}
else{
vt.pb(0);
}
}
for(int k=0;k<3;k++){
if(j&(1<<k)){
vt.pb(1);
}
else{
vt.pb(0);
}
}
if(arr[i]&(1<<j)){
vt.pb(1);
}
else{
vt.pb(0);
}
int ans=0;
for(int k=0;k<vt.size();k++){
if(vt[k]){
ans+=(1<<k);
}
}
send(ans);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
void decode(int n, int l, int arr[])
{
vector<vector<int>>vt(20,vector<int>(8));
for(int i=0;i<l;i++){
int k=arr[i];
int idx=0,pos=0;
for(int j=0;j<4;j++){
if(arr[i]&(1<<j)){
idx+=(1<<j);
}
}
for(int j=4;j<7;j++){
if(arr[i]&(1<<j)){
pos+=(1<<(j-4));
}
}
if(arr[i]&(1<<7)){
vt[idx][pos]=1;
}
else{
vt[idx][pos]=0;
}
}
for(int i=0;i<n;i++){
int ans=0;
for(int j=0;j<vt[i].size();j++){
if(vt[i][j]){
ans+=(1<<j);
}
}
output(ans);
}
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int k=0;k<vt.size();k++){
| ~^~~~~~~~~~
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:21:13: warning: unused variable 'k' [-Wunused-variable]
21 | int k=arr[i];
| ^
decoder.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int j=0;j<vt[i].size();j++){
| ~^~~~~~~~~~~~~
# | 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... |