結果

問題 No.769 UNOシミュレータ
ユーザー sigma425sigma425
提出日時 2018-12-19 01:32:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,514 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 146,676 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 11:57:41
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N,M;
	cin>>N>>M;
	V<int> a(N);
	int x = 0;
	int d = 1;
	string prev;
	int px = -1;
	int ren = 0;
	rep(i,M){
		px = x;
		string s;
		cin>>s;
		a[x]--;
		if(s == "number"){
			x = (x+d+N)%N;
			ren = 0;
		}
		if(s == "skip"){
			x = (x+d+d+N)%N;
			ren = 0;
		}
		if(s == "reverse"){
			d = -d;
			x = (x+d+N)%N;
			ren = 0;
		}
		if(s == "drawtwo"){
			if(prev == "drawtwo"){
				a[x]++;
				x = (x-d+N)%N;
				px = x;
				a[x]--;
				a[x] -= 2*ren;
				ren++;
			}else{
				ren = 1;
			}
			a[(x+d+N)%N] += 2*ren;
			x = (x+d+d+N)%N;
		}
		if(s == "drawfour"){
			if(prev == "drawfour"){
				a[x]++;
				x = (x-d+N)%N;
				px = x;
				a[x]--;
				a[x] -= 4*ren;
				ren++;
			}else{
				ren = 1;
			}
			a[(x+d+N)%N] += 4*ren;
			x = (x+d+d+N)%N;
		}
		prev = s;
	}
	cout<<px+1<<" "<<-a[px]<<endl;
}
0