結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー satanic
提出日時 2016-04-21 20:19:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 72,724 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 14:34:46
合計ジャッジ時間 1,321 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int t;
    std::cin >> t;
    for(int i=0; i<t; ++i){
        int n;
        std::cin >> n;
        std::vector<int> l(n);
        for(int j=0; j<n; ++j){
            std::cin >> l[j];
        }
        int ans = 0, readPos = 0;
        while(n>=3){
            #define END_FLAG (lNumWhenStart==readPos)
            int lNumWhenStart = l.size();
            std::vector<int> tmp;
            tmp.push_back(l[readPos++]);
            while(!END_FLAG && l[readPos]==tmp[0]){
                l.push_back(l[readPos++]);
            }
            if(END_FLAG) break;
            tmp.push_back(l[readPos++]);
            while(!END_FLAG && (l[readPos]==tmp[0] || l[readPos]==tmp[1])){
                l.push_back(l[readPos++]);
            }
            if(END_FLAG) break;
            tmp.push_back(l[readPos++]);
            ++ans;
            n-=3;
            #undef END_FLAG
        }
        std::cout << ans << "\n";
    }
    return 0;
}
                  
            
0