結果

問題 No.769 UNOシミュレータ
ユーザー pengin_2000pengin_2000
提出日時 2021-03-14 01:57:03
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-04-23 14:31:27
合計ジャッジ時間 1,161 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 11 ms
5,376 KB
testcase_13 AC 11 ms
5,376 KB
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 22 ms
5,376 KB
testcase_16 AC 21 ms
5,376 KB
testcase_17 AC 22 ms
5,376 KB
testcase_18 AC 31 ms
6,784 KB
testcase_19 AC 31 ms
6,912 KB
testcase_20 AC 31 ms
6,912 KB
testcase_21 AC 31 ms
6,912 KB
testcase_22 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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;
	if(l[m-1][4]=='\0')
		now = (now + n - step) % n;
	printf("%d %d\n", now + 1, cnt[now]);
	return 0;
}
0