# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26693 | grands | Question (Grader is different from the original contest) (CEOI14_question_grader) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
}