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 <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
#include "encoder.h"
#include "encoderlib.h"
using ll=long long;
using ld=long double;
int const INF=1000000005;
ll const LINF=1000000000000000005;
ll const mod=6700417;
ld const PI=3.14159265359;
ll const MAX_N=3e5+5;
ld const EPS=0.00000001;
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(a) (int)a.size()
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
map<ll,vector<ll>>viz;
string calc(ll nr){
string s="";
for(ll i=0;i<6;i++)
{
if((1ll<<i)&nr){
s+='1';
}else s+='0';
}
reverse(s.begin(),s.end());
return s;
}
int turnback(string s){
ll ans=0,d=0;
for(ll i=s.size()-1;i>=0;i--)
{
if(s[i]=='1'){
ans+=(1ll<<d);
}
d++;
}
return ans;
}
void encode(int n,int a[]){
ll val=0;
for(ll i1=0;i1<=3;i1++)
for(ll i2=i1;i2<=3;i2++)
for(ll i3=i2;i3<=3;i3++)
for(ll i4=i3;i4<=3;i4++)
for(ll i5=i4;i5<=3;i5++)
for(ll i6=i5;i6<=3;i6++)
for(ll i7=i6;i7<=3;i7++)
{
for(ll i8=i7;i8<=3;i8++){
vector<ll>x;
x.pb(i1);
x.pb(i2);
x.pb(i3);
x.pb(i4);
x.pb(i5);
x.pb(i6);
x.pb(i7);
x.pb(i8);
viz[val]=x;
val++;
}
}
for(ll i=0;i<n;i++)
{
vector<ll>x=viz[a[i]];
string s=calc(i);
for(auto it : x){
if(it==0){
// continue;
s+='0';
s+='0';
}else if(it==1){
s+='0';
s+='1';
}else if(it==2){
s+='1';
s+='0';
}else if(it==3){
s+='1';
s+='1';
}
send(turnback(s));
s.pop_back();
s.pop_back();
s.pop_back();
}
}
}
/*
int32_t main(){
int n,a[25];
n=8;
a[0]=1;
a[1]=0;
a[2]=1;
a[3]=0;
a[4]=0;
a[5]=1;
a[6]=1;
a[7]=0;
encode(n,a);
}
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
#include "decoder.h"
#include "decoderlib.h"
using ll=long long;
using ld=long double;
int const INF=1000000005;
ll const LINF=1000000000000000005;
ll const mod=6700417;
ld const PI=3.14159265359;
ll const MAX_N=3e5+5;
ld const EPS=0.00000001;
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(a) (int)a.size()
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
map<vector<ll>,ll>viz;
string calc(ll nr){
string s="";
for(ll i=0;i<9;i++)
{
if((1ll<<i)&nr){
s+='1';
}else s+='0';
}
reverse(s.begin(),s.end());
return s;
}
int turnback(string s){
ll ans=0,d=0;
for(ll i=s.size()-1;i>=0;i--)
{
if(s[i]=='1'){
ans+=(1ll<<d);
}
d++;
}
return ans;
}
void decode(int n,int m,int a[]){
ll val=0;
for(ll i1=0;i1<=3;i1++)
for(ll i2=i1;i2<=3;i2++)
for(ll i3=i2;i3<=3;i3++)
for(ll i4=i3;i4<=3;i4++)
for(ll i5=i4;i5<=3;i5++)
for(ll i6=i5;i6<=3;i6++)
for(ll i7=i6;i7<=3;i7++)
{
for(ll i8=i7;i8<=3;i8++){
vector<ll>x;
x.pb(i1);
x.pb(i2);
x.pb(i3);
x.pb(i4);
x.pb(i5);
x.pb(i6);
x.pb(i7);
x.pb(i8);
viz[x]=val;
val++;
}
}
vector<ll>g[65];
for(ll i=0;i<m;i++)
{
string s=calc(a[i]);
string x="";
x+=s.back();
s.pop_back();
x+=s.back();
s.pop_back();
x+=s.back();
s.pop_back();
swap(x[0],x[2]);
ll pos=turnback(s);
ll val=turnback(x);
g[pos].pb(val);
}
for(ll i=0;i<n;i++)
sort(g[i].begin(),g[i].end());
int ans[65];
for(ll i=0;i<n;i++)
output(viz[g[i]]);
}
Compilation message (stderr)
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:85:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
85 | for(ll i=0;i<n;i++)
| ^~~
decoder.cpp:87:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
87 | int ans[65];
| ^~~
decoder.cpp:87:9: warning: unused variable 'ans' [-Wunused-variable]
87 | int ans[65];
| ^~~
# | 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... |