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 forn(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
map<int, vector<int>> mp;
set<vector<int>> st;
int idx = 0;
void generate(vector<int> v) {
if(st.count(v)) return;
if(sz(v)) {
st.insert(v);
mp[idx] = v;
++idx;
}
if(sz(v) <= 6) {
if(!sz(v)) {
for(int i = 0; i < 4; ++i) {
v.pb(i);
generate(v);
v.pop_back();
}
} else {
for(int i = v.back(); i < 4; ++i) {
v.pb(i);
generate(v);
v.pop_back();
}
}
}
}
void encode(int n, int a[]) {
generate({});
vector<int> v;
for(int i = 0; i < n; ++i) {
int number = i * 4;
for(auto x: mp[a[i]]) {
for(int j = 0; j < 2; ++j) {
if(x & (1 << j)) number += (1 << j);
}
send(number);
for(int j = 0; j < 2; ++j) {
if(x & (1 << j)) number -= (1 << j);
}
}
}
}
/*
void solve() {
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
}
*/
#include "decoder.h"
#include "decoderlib.h"
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
map<int, vector<int>> mp;
map<vector<int>, int> Paiu;
set<vector<int>> st;
int idx = 0;
void generate(vector<int> v) {
if(st.count(v)) return;
if(sz(v)) {
st.insert(v);
mp[idx] = v;
Paiu[v] = idx;
++idx;
}
if(sz(v) <= 6) {
if(!sz(v)) {
for(int i = 0; i < 4; ++i) {
v.pb(i);
generate(v);
v.pop_back();
}
} else {
for(int i = v.back(); i < 4; ++i) {
v.pb(i);
generate(v);
v.pop_back();
}
}
}
}
void decode(int n, int m, int purice[]) {
vector<int> b(m);
forn(i, m) b[i] = purice[i];
generate({});
vector<int> a(n, 0);
vector<int> v[n + 1];
for(auto x: b) {
int i = x;
int number = 0;
if(i & 1) ++number;
i /= 2;
if(i & 1) number += 2;
i /= 2;
v[i].pb(number);
}
for(int i = 0; i < n; ++i) sort(all(v[i]));
forn(i, n) {
a[i] = Paiu[v[i]];
output(a[i]);
}
}
/*
void solve() {
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
}
*/
# | 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... |