이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int dp[11][5];
void preprocess() {
rep(j, 4) {
dp[10][j] = 4 - j;
}
for (int i = 9; i >= 1; i--) {
rep(j, 4){
dp[i][j] = 0;
for (int c = j; c < 4; c++) {
dp[i][j] += dp[i + 1][c];
}
// cout << "i = " << i << " j = " << j << " dp = " << dp[i][j] << '\n';
}
}
rep(i, 11) {
dp[i][4] = 0;
}
// cout << "KON" << endl;
}
void encode(int n, int T[])
{
preprocess();
rep(i, n) {
int pot = 1 << 6;
int it = 1;
while (it <= 10) {
int c = 3;
while (dp[it][c] <= T[i]) {
c--;
}
// cout << "c = " << c << " x = " << i + pot * c << endl;
T[i] -= dp[it][c + 1];
send(i + pot * c);
it++;
}
// cout << "WTH" << endl;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int dp2[11][5];
void preprocess2() {
rep(j, 4) {
dp2[10][j] = 4 - j;
}
for (int i = 9; i >= 1; i--) {
rep(j, 4){
dp2[i][j] = 0;
for (int c = j; c < 4; c++) {
dp2[i][j] += dp2[i + 1][c];
}
// cout << "i = " << i << " j = " << j << " dp = " << dp[i][j] << '\n';
}
}
rep(i, 11) {
dp2[i][4] = 0;
}
// cout << "KON" << endl;
}
void decode(int n, int sz, int X[])
{
preprocess2();
vector<int> T[n];
rep(i, sz) {
int liczba = 0;
int pot = 1;
while (pot < 64) {
if (X[i] % 2 == 1) {
liczba += pot;
}
X[i] /= 2;
pot *= 2;
}
T[liczba].push_back(X[i]);
}
rep(i, n) {
sort(T[i].begin(), T[i].end());
// rep(j, T[i].size()) {
// cout << "i = " << i << " j = " << j << " T = " << T[i][j] << endl;
// }
int liczba = 0;
for (int it = 1; it <= 10; it++) {
liczba += dp2[it][T[i][it - 1] + 1];
}
cout << liczba << '\n';
output(liczba);
}
}
# | 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... |