結果
問題 | No.769 UNOシミュレータ |
ユーザー |
![]() |
提出日時 | 2018-12-19 01:32:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 1,514 bytes |
コンパイル時間 | 1,478 ms |
コンパイル使用メモリ | 160,500 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-22 08:51:06 |
合計ジャッジ時間 | 2,854 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#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; }