結果
| 問題 | 
                            No.1827 最長部分スーパーリッチ門松列列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             pockyny
                         | 
                    
| 提出日時 | 2022-01-28 22:14:35 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,132 bytes | 
| コンパイル時間 | 844 ms | 
| コンパイル使用メモリ | 92,708 KB | 
| 最終ジャッジ日時 | 2025-01-27 16:44:24 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 6 RE * 18 | 
ソースコード
#include <iostream>
#include <atcoder/segtree>
#include <vector>
using namespace std;
using namespace atcoder;
struct S{int le,ri,num;};
S e(){ return S{-1,-1,0};}
S op(S a,S b){
    if(a.le==-1 && b.le!=-1) return b;
    if(a.le!=-1 && b.le==-1) return a;
    if(a.le==-1 && b.le==-1) return e();
    int nnum = a.num + b.num + (a.ri!=b.le);
    return {a.le,b.ri,nnum};
}
int p[300010],q[300010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t; cin >> t;
    while(t){
        t--;
        int i,n; cin >> n;
        for(i=0;i<n;i++) cin >> p[i];
        for(i=0;i<n;i++) q[p[i] - 1] = i;
        vector<S> v(n);
        for(i=0;i<n;i++) v[i] = {0,0,0};
        segtree<S,op,e> seg(v);
        int ans = -1;
        for(i=0;i<n;i++){
            int j = q[i];
            seg.set(j,S{1,1,0});
            ans = max(ans,seg.all_prod().num);
            /*for(int j=0;j<n;j++){
                cout << "(" << seg.prod(j,j + 1).le << "," << seg.prod(j,j + 1).ri << "," << seg.prod(j,j + 1).num << ") ";
            }*/
            //cout << endl;
        }
        cout << ans + 1<< "\n";
    }
}
            
            
            
        
            
pockyny