Skip to content

Instantly share code, notes, and snippets.

@orisano
Created November 11, 2012 13:30
Show Gist options
  • Save orisano/4054886 to your computer and use it in GitHub Desktop.
Save orisano/4054886 to your computer and use it in GitHub Desktop.
PCK本戦1問目:後になって書いてみた編
#include <stdio.h>
enum {A, X, Y, Z, W, B, ERROR};
int map[6][2] = {
{X, Y},
{ERROR, Z},
{X, ERROR},
{W, B},
{B, Y},
{Y, X}
};
int main(void)
{
int sw;
int now_pos;
for (now_pos = A; (sw = getchar()) != '#';){
if (sw == '\n'){
puts(now_pos == B ? "Yes" : "No");
now_pos = A;
continue;
}
if (now_pos == ERROR) continue;
now_pos = map[now_pos][sw == '1'];
}
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment