이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getWays(int dif, int len) {
if(dif == 0) return 0;
vector<vll> dp;
dp.assign(len,vll(dif,0));
RE(i,dif) dp[0][i] = i+1;
REP(i,1,len) RE(j,dif) {
if(j) dp[i][j] += dp[i][j-1];
dp[i][j] += dp[i-1][j];
}
return dp[len-1][dif-1];
}
vll encode(int x, int mx, int len) {
if(len == 0) return {};
RE1(i,mx) {
if(getWays(i,len) >= x) {
vll res = encode(x-getWays(i-1,len), i, len-1);
res.pb(i);
return res;
}
}
return {};
}
void encode(int N, int M[]) {
const int DIF = 5;
const int LEN = 7;
RE(i,N) {
vll v = encode(M[i]+1, DIF, LEN);
FOR(j,v) j-=2;
RE(j,7)
if(v[j] != -1)
send((i<<2)|v[j]);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getWays(int dif, int len) {
vector<vll> dp;
dp.assign(len,vll(dif,0));
RE(i,dif) dp[0][i] = i+1;
REP(i,1,len) RE(j,dif) {
if(j) dp[i][j] += dp[i][j-1];
dp[i][j] += dp[i-1][j];
}
return dp[len-1][dif-1];
}
int decode(vll v) {
if(v.empty()) return 1;
int last = v.back();
v.pop_back();
int res = decode(v);
res += getWays(last-1, v.size()+1);
return res;
}
void decode(int N, int L, int X[]) {
RE(i,N) {
output(1);
}
}
# | 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... |