#include // scanfとprintfを使うおまじない int nextTern(int t, int N, int isAsc) { if (isAsc == 1) { if (t == N) { t = 1; } else { t += 1; } } else { if (t == 1) { t = N; } else { t -= 1; } } return t; } int main(int argc, char *argv[]){ int N, M, i; char S[11]; int whosTern = 1; int isAsc = 0; int drowTwoCnt = 0; int drowFourCnt = 0; // 標準入力から読み込む(空白や改行で勝手に区切ってくれる) // 逆に空白込みの文字列を読み込む場合は別の方法で読む必要がある。 scanf("%d%d", &N, &M); int hands[N]; for (i=0; i 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } else if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; } else if (S == "skip") { if (drowTwoCnt > 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } else if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; nextTern(whosTern, N, isAsc); } else if (S == "reverse") { if (drowTwoCnt > 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } else if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; if (isAsc == 0) { isAsc = 1; } else { isAsc = 0; } } else if (S == "drawtwo") { if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; drowTwoCnt += 1; } else if (S == "drawfour") { if (drowTwoCnt > 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } hands[whosTern-1] += 1; drowFourCnt += 1; } } // 標準出力に出力 printf("%d %d\n", whosTern, hands[whosTern-1]); return 0; }