# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
520214 |
2022-01-28T21:15:21 Z |
new_acc |
Saveit (IOI10_saveit) |
C++14 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(a, b) for(int a = 0; a < (b); a++)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<ll> vl;
const int N=1e3+10;
vi graf[N];
int odl[N],oj[N];
int s[N];
bool vis[N];
void dfs(int v,int o){
vis[v]=1;
oj[v]=o;
for(auto u:graf[v]){
if(vis[u]) continue;
dfs(u,v);
}
}
void bfs(int x,int n){
rep(i,n) odl[i]=-1;
deque<int> deq;
odl[x]=0;
deq.push_back(x);
while(!deq.empty()){
int v=deq.front();
deq.pop_front();
for(auto u:graf[v]) if(odl[v]==-1) deq.push_back(u),odl[u]=odl[v]+1;
}
}
void encode(int n,int h,int p,int a[],int b[]){
rep(i,p) graf[a[i]].push_back(b[i]),graf[b[i]].push_back(a[i]);
dfs(0,0);
rep(i,n){
rep(j,10){
if(oj[i]&(1<<j)) encode_bit(1);
else encode_bit(0);
}
}
rep(i,h){
bfs(i,n);
rep(j,n){
if(odl[j]==odl[oj[j]]+1) encode_bit(0),encode_bit(0);
if(odl[j]==odl[oj[j]]) encode_bit(0),encode_bit(1);
if(odl[j]+1==odl[oj[j]]) encode_bit(1),encode_bit(1);
}
}
}
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(a, b) for(int a = 0; a < (b); a++)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<ll> vl;
const int N=1e3+10;
vi graf[N];
int odl[N],oj[N];
int s[N];
bool vis[N];
void decode(int n,int h){
rep(i,n) graf[i].clear();
rep(i,n){
int x=0;
rep(j,10){
int xd=decode_bit();
if(xd==1) x+=(1<<j);
}
graf[i].push_back(x),graf[x].push_back(i);
oj[i]=x;
}
rep(i,h){
deque<int> deq;
deq.push_back(i);
rep(j,n) vis[j]=0;
odl[i]=0,vis[i]=1;
rep(j,n){
bool xd=decode_bit(),xd2=decode_bit();
if(!xd and !xd2) s[j]=3;
if(!xd and xd2) s[j]=1;
if(xd and xd2) s[j]=0;
}
while(!deq.empty()){
int v=deq.front();
deq.pop_front();
if(vis[oj[v]]){
if(s[v]==3) odl[v]=odl[oj[v]]-1;
if(s[v]==1) odl[v]=odl[oj[v]];
if(s[v]==0) odl[v]=odl[oj[v]]+1;
}else{
if(s[v]==3) odl[oj[v]]=odl[v]+1;
if(s[v]==1) odl[oj[v]]=odl[v];
if(s[v]==0) odl[oj[v]]=odl[v]-1;
}
for(auto u:graf[v]) if(!vis[u]) deq.push_back(u),vis[u]=1;
}
rep(j,n) hops(i,j,odl[j]);
}
}
Compilation message
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:38:21: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
38 | if(oj[i]&(1<<j)) encode_bit(1);
| ^~~~~~~~~~
| encode
encoder.cpp:39:9: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
39 | else encode_bit(0);
| ^~~~~~~~~~
| encode
encoder.cpp:45:29: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
45 | if(odl[j]==odl[oj[j]]+1) encode_bit(0),encode_bit(0);
| ^~~~~~~~~~
| encode
encoder.cpp:46:27: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
46 | if(odl[j]==odl[oj[j]]) encode_bit(0),encode_bit(1);
| ^~~~~~~~~~
| encode
encoder.cpp:47:29: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
47 | if(odl[j]+1==odl[oj[j]]) encode_bit(1),encode_bit(1);
| ^~~~~~~~~~
| encode
decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:19:11: error: 'decode_bit' was not declared in this scope; did you mean 'decode'?
19 | int xd=decode_bit();
| ^~~~~~~~~~
| decode
decoder.cpp:31:12: error: 'decode_bit' was not declared in this scope; did you mean 'decode'?
31 | bool xd=decode_bit(),xd2=decode_bit();
| ^~~~~~~~~~
| decode
decoder.cpp:32:16: error: 'xd2' was not declared in this scope; did you mean 'xd'?
32 | if(!xd and !xd2) s[j]=3;
| ^~~
| xd
decoder.cpp:33:15: error: 'xd2' was not declared in this scope; did you mean 'xd'?
33 | if(!xd and xd2) s[j]=1;
| ^~~
| xd
decoder.cpp:34:14: error: 'xd2' was not declared in this scope; did you mean 'xd'?
34 | if(xd and xd2) s[j]=0;
| ^~~
| xd
decoder.cpp:50:12: error: 'hops' was not declared in this scope
50 | rep(j,n) hops(i,j,odl[j]);
| ^~~~