結果

問題 No.769 UNOシミュレータ
ユーザー FF256grhyFF256grhy
提出日時 2018-12-17 20:16:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 1,485 ms
コンパイル使用メモリ 166,908 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2023-08-14 11:55:37
合計ジャッジ時間 3,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
12,772 KB
testcase_01 AC 4 ms
12,752 KB
testcase_02 AC 4 ms
12,796 KB
testcase_03 AC 5 ms
12,776 KB
testcase_04 AC 6 ms
12,716 KB
testcase_05 AC 6 ms
12,712 KB
testcase_06 AC 6 ms
12,716 KB
testcase_07 AC 6 ms
12,776 KB
testcase_08 AC 4 ms
12,856 KB
testcase_09 AC 6 ms
12,808 KB
testcase_10 AC 7 ms
12,804 KB
testcase_11 AC 7 ms
13,060 KB
testcase_12 AC 33 ms
12,852 KB
testcase_13 AC 33 ms
13,032 KB
testcase_14 AC 33 ms
12,856 KB
testcase_15 AC 60 ms
13,092 KB
testcase_16 AC 60 ms
13,056 KB
testcase_17 AC 60 ms
13,184 KB
testcase_18 AC 86 ms
13,060 KB
testcase_19 AC 86 ms
13,092 KB
testcase_20 AC 93 ms
13,084 KB
testcase_21 AC 86 ms
13,084 KB
testcase_22 AC 6 ms
12,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define inc(i, n) for(int i = 0; i < (n); i++)

int n, m, x[100000];
string s[300001];

int main() {
	cin >> n >> m;
	inc(i, m) { cin >> s[i]; }
	
	string t;
	inc(i, m) {
		if(s[i] == "number"  ) { t += "x"; }
		if(s[i] == "skip"    ) { t += "x-"; }
		if(s[i] == "reverse" ) { t += "r"; }
		if(s[i] == "drawtwo" ) { t += "2"; if(s[i + 1] != s[i]) { t += "-"; } }
		if(s[i] == "drawfour") { t += "4"; if(s[i + 1] != s[i]) { t += "-"; } }
	}
	if(t.back() == '-') { t.pop_back(); }
	
	int p = -1, d = +1, c = 0;
	inc(i, t.size()) {
		p = (p + d + n) % n;
		if(t[i] == '-') {
			x[p] -= c;
			c = 0;
		} else {
			x[p]++;
			if(t[i] == 'r') { d *= -1; }
			if(t[i] == '2') { c += 2; }
			if(t[i] == '4') { c += 4; }
		}
	}
	
	cout << p + 1 << " " << x[p] << endl;
	
	return 0;
}
0