#include #include #include // Yukicoder №149 碁石の移動 ★☆ // https://yukicoder.me/problems/no/149 // *********************** #define gc(c) do{c = getchar_unlocked();}while(0) #define pc(c) putchar_unlocked(c) extern char getchar_unlocked(void); extern void putchar_unlocked(char c); static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];gc(c);while(c!=EOF){if((c==' ')||(c=='\n'))break;*cp++=c;gc(c);}*cp='\0';return &str[0];} #define str_len(a) mystr_len_lim(a,9999) static int mystr_len_lim(char *str,int lim){int i=0;do{if(str[i]=='\0')break;i++;}while(ib){return a;}return b;} static int min(int a,int b){if(a