結果

問題 No.769 UNOシミュレータ
ユーザー pengin_2000pengin_2000
提出日時 2021-03-14 01:55:07
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 878 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 14:31:15
合計ジャッジ時間 1,421 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 12 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 24 ms
5,376 KB
testcase_16 AC 25 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 33 ms
6,912 KB
testcase_19 AC 34 ms
6,912 KB
testcase_20 AC 35 ms
6,948 KB
testcase_21 AC 34 ms
6,912 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	char l[300005][16];
	int i;
	for (i = 0; i < m; i++)
		scanf("%s", l[i]);
	int now = 0, step = 1, stack = 0;
	int cnt[100005];
	for (i = 0; i < n; i++)
		cnt[i] = 0;
	for (i = 0; i < m; i++)
	{
		if (stack > 0)
		{
			if (l[i - 1][4] != l[i][4])
			{
				cnt[now] -= stack;
				stack = 0;
				now = (now + n + step) % n;
			}
		}
		if (l[i][4] == 'e')
			cnt[now]++;
		else if (l[i][4] == '\0')
		{
			cnt[now]++;
			now = (now + n + step) % n;
		}
		else if (l[i][4] == 'r')
		{
			cnt[now]++;
			step *= -1;
		}
		else if (l[i][4] == 't')
		{
			cnt[now]++;
			stack += 2;
		}
		else if (l[i][4] == 'f')
		{
			cnt[now]++;
			stack += 4;
		}
		now = (now + n + step) % n;
	}
	now = (now + n - step) % n;
	printf("%d %d\n", now + 1, cnt[now]);
	if (cnt[now] == 0)
	{
		printf("%d %d\n", n, m);
	}
	return 0;
}
0