結果

問題 No.769 UNOシミュレータ
ユーザー finefine
提出日時 2018-12-24 01:38:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 166,880 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 11:59:51
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 12 ms
4,384 KB
testcase_15 AC 21 ms
4,380 KB
testcase_16 AC 22 ms
4,384 KB
testcase_17 AC 22 ms
4,380 KB
testcase_18 AC 35 ms
4,384 KB
testcase_19 AC 30 ms
4,384 KB
testcase_20 AC 32 ms
4,384 KB
testcase_21 AC 32 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int cur = 0;
	const int INF = 1000000000;
	vector<int> num(n, INF);
	int add = 1;
	int cnt2 = 0, cnt4 = 0;
	for (int i = 0; i < m; i++) {
		string s;
		cin >> s;
		if (cnt2 > 0 && s != "drawtwo") {
			num[cur] += cnt2 * 2;
			cnt2 = 0;
			cur = (cur + add + n) % n;
		}
		if (cnt4 > 0 && s != "drawfour") {
			num[cur] += cnt4 * 4;
			cnt4 = 0;
			cur = (cur + add + n) % n;
		}

		int nex = cur;
		if (s == "drawtwo") {
			num[cur]--;
			cnt2++;
			nex = (cur + add + n) % n;
		} else if (s == "drawfour") {
			num[cur]--;
			cnt4++;
			nex = (cur + add + n) % n;
		} else if (s == "skip") {
			num[cur]--;
			nex = (cur + add * 2 + n) % n;
		} else if (s == "reverse") {
			num[cur]--;
			add = -add;
			nex = (cur + add + n) % n;
		} else {
			num[cur]--;
			nex = (cur + add + n) % n;
		}

		if (i + 1 == m) cout << cur + 1 << " " << INF - num[cur] << endl;
		else cur = nex;
	}
	return 0;
}
0