#include "encoder.h"
#include "encoderlib.h"
void encode(int N, int M[]) {
for(int i = 0; i < N; i++) {
int t, a, b, c, cnt = 0;
for(t = 0; t <= 7 and cnt < M[i]; t++){
for(a = 0; a <= t and cnt < M[i]; a++) {
for(b = 0; a+b <= t and cnt < M[i]; b++) {
for(c = 0; a+b+c <= t and cnt < M[i]; c++) {
cnt++;
}
}
}
}
t--; a--; b--; c--;
for(int j = 1; j <= a; j++) send(4*i);
for(int j = 1; j <= b; j++) send(4*i+1);
for(int j = 1; j <= c; j++) send(4*i+2);
for(int j = 1; j <= t-a-b-c; j++) send(4*i+3);
}
}
#include<bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
void decode(int N, int L, int X[]) {
int qtd[256];
memset(qtd, 0, sizeof(qtd));
for(int i = 0; i < L; i++)
qtd[X[i]]++;
for(int i = 0; i < N; i++) {
int a = qtd[4*i], b = qtd[4*i+1], c = qtd[4*i+2], t = a+b+c+qtd[4*i+3], cnt = 0;
for(int t1 = 0; t1 <= 7 and cnt >= 0; t1++){
for(int a1 = 0; a1 <= t1 and cnt >= 0; a1++) {
for(int b1 = 0; a1+b1 <= t1 and cnt >= 0; b1++) {
for(int c1 = 0; a1+b1+c1 <= t1 and cnt >= 0; c1++) {
cnt++;
if(t1 != t or a1 != a or b1 != b or c1 != c) continue;
output(cnt);
cnt = -1;
}
}
}
}
}
}
Compilation message
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:19:21: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
19 | t--; a--; b--; c--;
| ~^~
encoder.cpp:19:16: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
19 | t--; a--; b--; c--;
| ~^~
encoder.cpp:19:11: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
19 | t--; a--; b--; c--;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
784 KB |
Error : Encoded message too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
800 KB |
Error : Encoded message too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
784 KB |
Error : Encoded message too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
784 KB |
Error : Encoded message too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
784 KB |
Error : Encoded message too long |
2 |
Incorrect |
0 ms |
800 KB |
Error : Encoded message too long |
3 |
Incorrect |
0 ms |
804 KB |
Error : Encoded message too long |
4 |
Incorrect |
0 ms |
792 KB |
Error : Encoded message too long |
5 |
Incorrect |
0 ms |
804 KB |
Error : Encoded message too long |
6 |
Incorrect |
0 ms |
804 KB |
Error : Encoded message too long |
7 |
Incorrect |
0 ms |
808 KB |
Error : Encoded message too long |