結果

問題 No.769 UNOシミュレータ
ユーザー finefine
提出日時 2018-12-24 01:38:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 168,396 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 08:55:59
合計ジャッジ時間 2,862 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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