結果
| 問題 |
No.2697 Range LIS Query
|
| コンテスト | |
| ユーザー |
arad
|
| 提出日時 | 2024-03-22 23:16:02 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,177 bytes |
| コンパイル時間 | 5,671 ms |
| コンパイル使用メモリ | 326,400 KB |
| 実行使用メモリ | 129,892 KB |
| 最終ジャッジ日時 | 2024-09-30 12:30:44 |
| 合計ジャッジ時間 | 18,089 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
struct S{
VVL x;
ll len;
S():x(4,VL(4)),len(0){}
};
using F = ll;
S op(S a,S b){
S c;
rep(d,4)rep(i,4){
ll j = i+d;
if(j >= 4) continue;
ll mx = 0;
for(ll k = i;k <= j;k++){
chmax(mx,a.x[i][k]);
chmax(c.x[i][j],mx+b.x[k][j]);
}
}
c.len = a.len+b.len;
return c;
}
S e(){
S res;
res.len = 0;
return res;
}
S mapping(F f,S x){
if(f==INF){
return x;
}
rep(i,4)rep(j,4) x.x[i][j] = 0;
x.x[f][f] = x.len;
return x;
}
F composition(F f,F g){
if(f==INF) return g;
else return f;
}
F id(){
return INF;
}
int main(){
ll n;
cin >> n;
vector<S> v(n);
rep(i,n){
ll a;
cin >> a;
a--;
v[i].len = 1;
v[i].x[a][a] = 1;
}
lazy_segtree<S,op,e,F,mapping,composition,id> seg(v);
ll q;
cin >> q;
rep(qi,q){
ll t,l,r;
cin >> t >> l >> r;
l--;
if(t==1){
ll ans = 0;
rep(i,4)rep(j,i+1) chmax(ans,seg.prod(l,r).x[j][i]);
out(ans);
}
if(t==2){
ll x;
cin >> x;
x--;
seg.apply(l,r,x);
}
}
}
arad