結果
問題 |
No.1219 Mancala Combo
|
ユーザー |
|
提出日時 | 2022-07-04 15:31:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,114 bytes |
コンパイル時間 | 2,134 ms |
コンパイル使用メモリ | 202,968 KB |
最終ジャッジ日時 | 2025-01-30 04:34:08 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 TLE * 12 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/lazysegtree> using namespace std; using namespace atcoder; const int inf = 1 << 30; struct S{ int ind; int min_; }; using F = int; S e(){ return S{-1, inf}; } S op(S l, S r){ if(l.min_ <= r.min_) return l; else return r; } S mapping(F l, S r){ return S({r.ind, r.min_ + l}); } F composition(F l, F r){ return l + r; } F id(){ return 0; } void solve(){ int n, a; cin >> n; vector<S> A(n); for(int i = 0; i < n; i++){ cin >> a; A[i].ind = i; A[i].min_ = i + 1 - a; } lazy_segtree<S, op, e, F, mapping, composition, id> seg(A); while(1){ S tmp = seg.prod(0, n); if(tmp.min_ != 0) break; seg.apply(0, tmp.ind, -1); seg.apply(tmp.ind, tmp.ind + 1, tmp.ind + 1); } for(int i = 0; i < n; i++){ if(seg.get(i).min_ != i + 1){ cout << "No\n"; return; } } cout << "Yes\n"; } int main(){ cin.tie(0)->sync_with_stdio(0); int t; t = 1; //cin >> t; while(t--) solve(); }