結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー satanicsatanic
提出日時 2016-04-21 20:19:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 70,692 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 03:57:50
合計ジャッジ時間 1,335 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

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