#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef int INT;
#define FOR(i,l,r) for(int i = (l); i < (r); i++)
#define snd second
#define fst first
#define V vector
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
void encode(int N, int M[]){
if(N < 16) FOR(i, 0, N) FOR(j, 0, 8) {if(M[i]&(1<<j)) send( (i<<3)+j);}
else {
vi bestcode;
int bestcnt = 1e9;
FOR(seed, 0, 256){
srand(seed);
int cnt = 0;
vi code(256, 0);
FOR(i, 0, N) {
int r = (rand() % 256);
FOR(j, 0, 4){
int m = M[i] ^ r;
int k = (m>>(2*j))& 3 ;
//cerr << cnt << endl;
code[( (i<<2)+j)] += k;
cnt += k;
}
}
code[seed] += 4;
cnt += 4;
if(cnt < bestcnt) {
bestcnt = cnt;
bestcode = code;
}
}
//cout<<bestcnt<<endl;
//for(int k : bestcode) cout << k << " ";
//cout<<endl;
FOR(i, 0, 256)FOR(j, 0, bestcode[i]) send(i);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef int INT;
#define FOR(i,l,r) for(int i = (l); i < (r); i++)
#define snd second
#define fst first
#define V vector
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
void decode(int N, int L, int X[]) {
if(N < 16){
vi msg(N, 0) ;
FOR(i, 0, L) msg[ (X[i]) >>3] |= 1<<(X[i]&7);
FOR(i, 0, N) output(msg[i]);
} else {
//cerr << "{ ";
//FOR(i, 0, 64) cerr << rand() % 256 << ", ";
//cerr << "}"<<endl;
vi msg(256, 0);
FOR(i, 0, L) msg[X[i]]++;
int seed = 0;
for(; msg[seed] < 4; seed++);
srand(seed);
FOR(i, 0, N) {
int c = 0;
FOR(k, 0, 4) c |= (msg[4*i+k] & 3) << (2*k);
c ^= (rand() % 256);
//cerr<<c<<endl;
output(c);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1600 KB |
Output is correct |
2 |
Correct |
6 ms |
1872 KB |
Output is correct |
3 |
Correct |
6 ms |
2072 KB |
Output is correct |
4 |
Correct |
33 ms |
2072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2072 KB |
Output is correct |
2 |
Correct |
7 ms |
2080 KB |
Output is correct |
3 |
Correct |
7 ms |
2112 KB |
Output is correct |
4 |
Correct |
36 ms |
2112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2144 KB |
Output is correct |
2 |
Correct |
35 ms |
2176 KB |
Output is correct |
3 |
Correct |
46 ms |
2176 KB |
Output is correct |
4 |
Correct |
38 ms |
2176 KB |
Output is correct |
5 |
Correct |
38 ms |
2176 KB |
Output is correct |
6 |
Correct |
40 ms |
2432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
36 ms |
2432 KB |
Output is partially correct - P = 5.062500 |
2 |
Partially correct |
39 ms |
2432 KB |
Output is partially correct - P = 5.281250 |
3 |
Partially correct |
43 ms |
2432 KB |
Output is partially correct - P = 5.242424 |
4 |
Partially correct |
44 ms |
2440 KB |
Output is partially correct - P = 5.420000 |
5 |
Partially correct |
54 ms |
2440 KB |
Output is partially correct - P = 5.416667 |
6 |
Partially correct |
54 ms |
2584 KB |
Output is partially correct - P = 5.428571 |
7 |
Partially correct |
62 ms |
2584 KB |
Output is partially correct - P = 5.421875 |