結果

問題 No.769 UNOシミュレータ
ユーザー pengin_2000pengin_2000
提出日時 2021-03-14 01:27:06
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 800 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 14:30:10
合計ジャッジ時間 2,883 ms
ジャッジサーバーID
(参考情報)
judge3 / 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 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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