# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26693 | grands | Question (Grader is different from the original contest) (CEOI14_question_grader) | C++14 | 0 ms | 0 KiB |
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 <cstdlib>
#include <string.h>
#include <stdio.h>
int encode(int n, int x, int y) {
char N[100] = { 0 }, X[100] = { 0 }, Y[100] = { 0 };
itoa(n, N, 2);
//printf("n %d : %10s\n", n, N);
itoa(x, X, 2);
//printf("x %d : %10s\n", x, X);
itoa(y, Y, 2);
//printf("y %d : %10s\n", y, Y);
//printf("\n");
int i = strlen(N) - 1, j = strlen(X) - 1, k = strlen(Y) - 1;
int ret = 1;
while (true){
if (ret % 2 == 0 && N[i] == X[j] && X[j] != Y[k]){
return ret;
}
if (ret % 2 == 1 && N[i] == Y[k] && X[j] != Y[k]){
return ret;
}
i--;
j--;
k--;
if (i < 0){
N[0] = '0';
i = 0;
}
if (j < 0){
X[0] = '0';
j = 0;
}
if (k < 0){
Y[0] = '0';
k = 0;
}
ret++;
}
}
#include <cstdlib>
#include <stdio.h>
#include <string.h>
int decode (int n, int q, int h) {
char N[100] = { 0 }, Q[100] = { 0 } ;
itoa(n, N, 2);
itoa(q, Q, 2);
int i = strlen(N) - h, j = strlen(Q) - h;
if (h % 2 == 0){
//ret % 2 == 0 && N[i] == X[j] && X[j] != Y[k]
if (i < 0){
N[0] = '0';
i = 0;
}
if (j < 0){
Q[0] = '0';
j = 0;
}
return (N[i] == Q[j]);
}
else{
//ret % 2 == 1 && N[i] == Y[j] && X[j] != Y[k]
if (i < 0){
N[0] = '0';
i = 0;
}
if (j < 0){
Q[0] = '0';
j = 0;
}
return !(N[i] == Q[j]);
}
}