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;
vector<int> need={
0,1,2,3,4,10,11,12,13,20,21,22,30,31,40,100,101,102,103,110,111,112,120,121,130,200,201,202,210,211,220,300,301,310,400,1000,1001,1002,1003,1010,1011,1012,1020,1021,1030,1100,1101,1102,1110,1111,1120,1200,1201,1210,1300,2000,2001,2002,2010,2011,2020,2100,2101,2110,2200,3000,3001,3010,3100,4000,10000,10001,10002,10003,10010,10011,10012,10020,10021,10030,10100,10101,10102,10110,10111,10120,10200,10201,10210,10300,11000,11001,11002,11010,11011,11020,11100,11101,11110,11200,12000,12001,12010,12100,13000,20000,20001,20002,20010,20011,20020,20100,20101,20110,20200,21000,21001,21010,21100,22000,30000,30001,30010,30100,31000,40000,100000,100001,100002,100003,100010,100011,100012,100020,100021,100030,100100,100101,100102,100110,100111,100120,100200,100201,100210,100300,101000,101001,101002,101010,101011,101020,101100,101101,101110,101200,102000,102001,102010,102100,103000,110000,110001,110002,110010,110011,110020,110100,110101,110110,110200,111000,111001,111010,111100,112000,120000,120001,120010,120100,121000,130000,200000,200001,200002,200010,200011,200020,200100,200101,200110,200200,201000,201001,201010,201100,202000,210000,210001,210010,210100,211000,220000,300000,300001,300010,300100,301000,310000,400000,1000000,1000001,1000002,1000003,1000010,1000011,1000012,1000020,1000021,1000030,1000100,1000101,1000102,1000110,1000111,1000120,1000200,1000201,1000210,1000300,1001000,1001001,1001002,1001010,1001011,1001020,1001100,1001101,1001110,1001200,1002000,1002001,1002010,1002100,1003000,1010000,1010001,1010002,1010010,1010011,1010020,1010100,1010101,1010110,1010200,1011000};
void encode(int n, int m[])
{
int dig=0;
for(int i=0;i<n;i++){
int x=need[m[i]^(i+1)];
for(int j=0;j<7;j++){
dig+=x%10;
send((dig));
x/=10;
}
}
// cout<<dig<<endl;
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> need2={0,1,2,3,4,10,11,12,13,20,21,22,30,31,40,100,101,102,103,110,111,112,120,121,130,200,201,202,210,211,220,300,301,310,400,1000,1001,1002,1003,1010,1011,1012,1020,1021,1030,1100,1101,1102,1110,1111,1120,1200,1201,1210,1300,2000,2001,2002,2010,2011,2020,2100,2101,2110,2200,3000,3001,3010,3100,4000,10000,10001,10002,10003,10010,10011,10012,10020,10021,10030,10100,10101,10102,10110,10111,10120,10200,10201,10210,10300,11000,11001,11002,11010,11011,11020,11100,11101,11110,11200,12000,12001,12010,12100,13000,20000,20001,20002,20010,20011,20020,20100,20101,20110,20200,21000,21001,21010,21100,22000,30000,30001,30010,30100,31000,40000,100000,100001,100002,100003,100010,100011,100012,100020,100021,100030,100100,100101,100102,100110,100111,100120,100200,100201,100210,100300,101000,101001,101002,101010,101011,101020,101100,101101,101110,101200,102000,102001,102010,102100,103000,110000,110001,110002,110010,110011,110020,110100,110101,110110,110200,111000,111001,111010,111100,112000,120000,120001,120010,120100,121000,130000,200000,200001,200002,200010,200011,200020,200100,200101,200110,200200,201000,201001,201010,201100,202000,210000,210001,210010,210100,211000,220000,300000,300001,300010,300100,301000,310000,400000,1000000,1000001,1000002,1000003,1000010,1000011,1000012,1000020,1000021,1000030,1000100,1000101,1000102,1000110,1000111,1000120,1000200,1000201,1000210,1000300,1001000,1001001,1001002,1001010,1001011,1001020,1001100,1001101,1001110,1001200,1002000,1002001,1002010,1002100,1003000,1010000,1010001,1010002,1010010,1010011,1010020,1010100,1010101,1010110,1010200,1011000};
void decode(int n, int l, int dig[])
{
sort(dig,dig+l);
int ind = 1;
for(int i=0;i<l;i+=7){
int res=0;
int tem=1;
for(int j=i;j<i+7;j++){
//dig[j]^=j;
if(j==0){
res+=(dig[j]*tem);
}else{
res += (dig[j]-dig[j-1])*tem;
}
tem*=10;
}
res=lower_bound(need2.begin(), need2.end(), res) - need2.begin();
output((res^(ind)));
// cout<<(res^(ind))<<endl;
ind++;
}
}
# | 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... |