| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 426332 | Kushagra_J | Memory (IOI10_memory) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "memory.h"
#include "grader.h"
#include <stdio.h>
#include <stdlib.h>
static char card[51];
static int up[2], is_up[51], candy[25], candies, moves;
void play() {
int i;
char a, b;
int candies=0;
for (i=1; i<=50; i++) {
a = faceup(i);
for (int j = i + 1; j <= 50; j++) {
b = faceup(j);
if(a==b)
{
candies++;
break;
}
}
}
}
char faceup(int C){
int c0, c1;
if (C < 1 || C > 50 || is_up[C]) {
exit(92);
}
is_up[C] = 1;
up[moves%2] = C;
moves++;
if (moves%2 == 0) {
c0 = card[ up[0] ] - 'A';
c1 = card[ up[1] ] - 'A';
if (c0==c1 && !candy[c0]) {
candy[c0] = 1;
++candies;
}
is_up[ up[0] ] = is_up[ up[1] ] = 0;
}
return card[C];
}
void playgame(){
int i;
for (i=1;i<=50;i++) {
card[i] = getchar();
}
moves = candies = 0;
play();
if (candies != 25) {
exit(91);
}
}
int main(){
playgame();
printf("OK %d\n",moves);
return 0;
}
