結果
| 問題 | No.769 UNOシミュレータ | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-02-26 11:27:11 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 24 ms / 2,000 ms | 
| コード長 | 836 bytes | 
| コンパイル時間 | 1,794 ms | 
| コンパイル使用メモリ | 169,744 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-22 09:34:08 | 
| 合計ジャッジ時間 | 2,749 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <bits/stdc++.h>
using longlong=long long;
int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n,q;std::cin>>n>>q;
    std::vector<int>a(n);
    int now=0,draw=0;
    std::string prv="$";
    bool reverse=false;
    auto increment=[&]{
        now=reverse?(now==0?n-1:now-1):(now==n-1?0:now+1);
    };
    for(int i=0;i<q;i++){
        std::string s;std::cin>>s;
        if(prv!=s&&0<draw){
            a.at(now)-=std::exchange(draw,0);
            increment();
        }
        a.at(now)++;
        if(i==q-1)break;
        if(s.front()=='r')reverse^=1;
        if(s.front()=='s')increment();
        if(s.front()=='d'){
            if(s.at(4)=='t')draw+=2;
            if(s.at(4)=='f')draw+=4;
        }
        increment();
        prv=s;
    }
    std::cout<<now+1<<" "<<a.at(now)<<std::endl;
}
            
            
            
        