#include "grader.h"
#include "encoder.h"
#include <vector>
#include <queue>
#include <iostream>
#include <cstring>
using namespace std;
void go(int x,int pw) {
for (int i = 0; i < pw; ++i) {
if (x&(1 << i))encode_bit(1);
else encode_bit(0);
}
}
bool used[1007];
int ans[1007];
vector<int> g[1007];
int par[1007];
void dfs(int v){
for(int to:g[v]){
if(par[to]!=0)continue;
par[to]=v;
dfs(to);
}
}
vector<int> vl;
void add(){
int ans=0;
int ast=1;
for(int i=0;i<10;++i){
ans+=ast*vl[i];
ast*=3;
}
go(ans,16);
vl.clear();
}
void add(int x){
vl.push_back(x+1);
if(vl.size()==10){
add();
}
}
void encode(int nv, int nh, int ne, int *v1, int *v2) {
for (int i = 0; i < ne; ++i) {
g[v1[i]].push_back(v2[i]); g[v2[i]].push_back(v1[i]);
}
par[0]=-1;
dfs(0);
for(int i=1;i<nv;++i){
go(par[i],10);
}
for (int i = 0; i < nh; ++i) {
queue<int> q;
memset(used, 0, sizeof(used));
memset(ans, 0, sizeof(ans));
used[i] = true;
ans[i] = 0;
q.push(i);
while (!q.empty()) {
int v = q.front(); q.pop();
for (int to : g[v]) {
if (used[to])continue;
used[to] = true;
ans[to] = ans[v] + 1;
q.push(to);
}
}
for (int j = 0; j < nv; ++j) {
if(ans[j]==ans[par[j]])add(0);
if(ans[j]==ans[par[j]]+1)add(1);
if(ans[j]==ans[par[j]]-1)add(-1);
}
}
if(vl.size()!=0)add();
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
int get(int pw) {
int x = 0;
for (int i = 0; i < pw; ++i) {
if (decode_bit() == 1)x += (1 << i);
}
return x;
}
vector<int> ls;
int cx=0;
int nxt(){
if(cx>=ls.size()){
cx=0;
int x=get(16);
int ast=1;
for(int i=0;i<10;++i)ast*=3;
for(int i=9;i>=0;i--){
ast/=3;
if(ast*2>=x){
ls.push_back(2);x-=ast*2;
}
else if(ast>=x){
ls.push_back(1);x-=ast;
}
else{
ls.push_back(0);
}
ast/=3;
}
}
return ls[cx++]-1;
}
const int N = 1007;
vector<int> gr[N];
int parr[N];
int val[N];
bool uss[N];
void cl(int v,int ans,int lv){
hops(v,lv,ans);
uss[v]=true;
for(auto to:gr[v]){
if(uss[to]==true)continue;
if(parr[v]==to){
cl(to,ans-val[to],lv);
}
else{
cl(to,ans+val[to],lv);
}
}
}
void decode(int nv, int nh) {
parr[0]=-1;
for(int i=1;i<nv;++i){
int x=get(10);
parr[i]=x;
gr[x].push_back(i);
gr[i].push_back(x);
}
for(int i=0;i<nh;++i){
for(int j=0;j<nv;++j){
val[j]=nxt();
}
memset(uss,0,sizeof(uss));
cl(i,0,i);
}
}
Compilation message
decoder.cpp: In function 'int nxt()':
decoder.cpp:15:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(cx>=ls.size()){
~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
365 ms |
11504 KB |
wrong parameter |
2 |
Incorrect |
7 ms |
4800 KB |
wrong parameter |
3 |
Incorrect |
25 ms |
5440 KB |
wrong parameter |
4 |
Incorrect |
7 ms |
4668 KB |
wrong parameter |
5 |
Incorrect |
36 ms |
5564 KB |
wrong parameter |
6 |
Incorrect |
35 ms |
5596 KB |
wrong parameter |
7 |
Incorrect |
64 ms |
6116 KB |
wrong parameter |
8 |
Incorrect |
24 ms |
5396 KB |
wrong parameter |
9 |
Incorrect |
26 ms |
5428 KB |
wrong parameter |
10 |
Incorrect |
25 ms |
5576 KB |
wrong parameter |
11 |
Incorrect |
40 ms |
5564 KB |
wrong parameter |
12 |
Incorrect |
27 ms |
5436 KB |
wrong parameter |
13 |
Incorrect |
54 ms |
5996 KB |
wrong parameter |
14 |
Incorrect |
26 ms |
5396 KB |
wrong parameter |
15 |
Incorrect |
30 ms |
5508 KB |
wrong parameter |
16 |
Incorrect |
62 ms |
5876 KB |
wrong parameter |
17 |
Incorrect |
57 ms |
6056 KB |
wrong parameter |
18 |
Incorrect |
82 ms |
6280 KB |
wrong parameter |
19 |
Incorrect |
49 ms |
5704 KB |
wrong parameter |
20 |
Incorrect |
126 ms |
6488 KB |
wrong parameter |
21 |
Incorrect |
115 ms |
6728 KB |
wrong parameter |
22 |
Incorrect |
66 ms |
6024 KB |
wrong parameter |
23 |
Incorrect |
112 ms |
6804 KB |
wrong parameter |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
365 ms |
11504 KB |
wrong parameter |
2 |
Incorrect |
7 ms |
4800 KB |
wrong parameter |
3 |
Incorrect |
25 ms |
5440 KB |
wrong parameter |
4 |
Incorrect |
7 ms |
4668 KB |
wrong parameter |
5 |
Incorrect |
36 ms |
5564 KB |
wrong parameter |
6 |
Incorrect |
35 ms |
5596 KB |
wrong parameter |
7 |
Incorrect |
64 ms |
6116 KB |
wrong parameter |
8 |
Incorrect |
24 ms |
5396 KB |
wrong parameter |
9 |
Incorrect |
26 ms |
5428 KB |
wrong parameter |
10 |
Incorrect |
25 ms |
5576 KB |
wrong parameter |
11 |
Incorrect |
40 ms |
5564 KB |
wrong parameter |
12 |
Incorrect |
27 ms |
5436 KB |
wrong parameter |
13 |
Incorrect |
54 ms |
5996 KB |
wrong parameter |
14 |
Incorrect |
26 ms |
5396 KB |
wrong parameter |
15 |
Incorrect |
30 ms |
5508 KB |
wrong parameter |
16 |
Incorrect |
62 ms |
5876 KB |
wrong parameter |
17 |
Incorrect |
57 ms |
6056 KB |
wrong parameter |
18 |
Incorrect |
82 ms |
6280 KB |
wrong parameter |
19 |
Incorrect |
49 ms |
5704 KB |
wrong parameter |
20 |
Incorrect |
126 ms |
6488 KB |
wrong parameter |
21 |
Incorrect |
115 ms |
6728 KB |
wrong parameter |
22 |
Incorrect |
66 ms |
6024 KB |
wrong parameter |
23 |
Incorrect |
112 ms |
6804 KB |
wrong parameter |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
365 ms |
11504 KB |
wrong parameter |
2 |
Incorrect |
7 ms |
4800 KB |
wrong parameter |
3 |
Incorrect |
25 ms |
5440 KB |
wrong parameter |
4 |
Incorrect |
7 ms |
4668 KB |
wrong parameter |
5 |
Incorrect |
36 ms |
5564 KB |
wrong parameter |
6 |
Incorrect |
35 ms |
5596 KB |
wrong parameter |
7 |
Incorrect |
64 ms |
6116 KB |
wrong parameter |
8 |
Incorrect |
24 ms |
5396 KB |
wrong parameter |
9 |
Incorrect |
26 ms |
5428 KB |
wrong parameter |
10 |
Incorrect |
25 ms |
5576 KB |
wrong parameter |
11 |
Incorrect |
40 ms |
5564 KB |
wrong parameter |
12 |
Incorrect |
27 ms |
5436 KB |
wrong parameter |
13 |
Incorrect |
54 ms |
5996 KB |
wrong parameter |
14 |
Incorrect |
26 ms |
5396 KB |
wrong parameter |
15 |
Incorrect |
30 ms |
5508 KB |
wrong parameter |
16 |
Incorrect |
62 ms |
5876 KB |
wrong parameter |
17 |
Incorrect |
57 ms |
6056 KB |
wrong parameter |
18 |
Incorrect |
82 ms |
6280 KB |
wrong parameter |
19 |
Incorrect |
49 ms |
5704 KB |
wrong parameter |
20 |
Incorrect |
126 ms |
6488 KB |
wrong parameter |
21 |
Incorrect |
115 ms |
6728 KB |
wrong parameter |
22 |
Incorrect |
66 ms |
6024 KB |
wrong parameter |
23 |
Incorrect |
112 ms |
6804 KB |
wrong parameter |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
365 ms |
11504 KB |
wrong parameter |
2 |
Incorrect |
7 ms |
4800 KB |
wrong parameter |
3 |
Incorrect |
25 ms |
5440 KB |
wrong parameter |
4 |
Incorrect |
7 ms |
4668 KB |
wrong parameter |
5 |
Incorrect |
36 ms |
5564 KB |
wrong parameter |
6 |
Incorrect |
35 ms |
5596 KB |
wrong parameter |
7 |
Incorrect |
64 ms |
6116 KB |
wrong parameter |
8 |
Incorrect |
24 ms |
5396 KB |
wrong parameter |
9 |
Incorrect |
26 ms |
5428 KB |
wrong parameter |
10 |
Incorrect |
25 ms |
5576 KB |
wrong parameter |
11 |
Incorrect |
40 ms |
5564 KB |
wrong parameter |
12 |
Incorrect |
27 ms |
5436 KB |
wrong parameter |
13 |
Incorrect |
54 ms |
5996 KB |
wrong parameter |
14 |
Incorrect |
26 ms |
5396 KB |
wrong parameter |
15 |
Incorrect |
30 ms |
5508 KB |
wrong parameter |
16 |
Incorrect |
62 ms |
5876 KB |
wrong parameter |
17 |
Incorrect |
57 ms |
6056 KB |
wrong parameter |
18 |
Incorrect |
82 ms |
6280 KB |
wrong parameter |
19 |
Incorrect |
49 ms |
5704 KB |
wrong parameter |
20 |
Incorrect |
126 ms |
6488 KB |
wrong parameter |
21 |
Incorrect |
115 ms |
6728 KB |
wrong parameter |
22 |
Incorrect |
66 ms |
6024 KB |
wrong parameter |
23 |
Incorrect |
112 ms |
6804 KB |
wrong parameter |