CodeForces - 1000D Yet Another Problem On a Subsequence
題面在這裏!
好智障的一個dp啊,一段開頭的數字相當於下面要跟多少個數,直接滾動數組dp就行了。。。
#include<bits/stdc++.h> #define ll long long using namespace std; const int N=1005,ha=998244353; inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;} int f[N],n,a[N]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); f[0]=1; for(int i=1,now;i<=n;i++){ now=f[0]; for(int j=0;j<n;j++) ADD(f[j],f[j+1]); if(a[i]>0&&a[i]+i<=n) ADD(f[a[i]],now); } ADD(f[0],ha-1),printf("%d\n",f[0]); return 0; }
CodeForces - 1000D Yet Another Problem On a Subsequence
相關推薦
CodeForces - 1000D Yet Another Problem On a Subsequence
CP get highlight #define oid brush for turn force 題面在這裏! 好智障的一個dp啊,一段開頭的數字相當於下面要跟多少個數,直接滾動數組dp就行了。。。 #include<bits/stdc++.h&g
Educational Codeforces Round 46 D. Yet Another Problem On a Subsequence
mod ons ++ 數列 一個數 () -- problem dot 題目大意 定義一個數列是“好的”:第一個數字a[0]為數列長度+1。 定義一個數列的子序列是“好的”:這個子序列能分割成幾個“好的”數列。 各一個數列,求“好的”子序列的數目。 解題思路 一開始想
CodeForces 863D Yet Another Array Queries Problem 暴力
names scanf amp pan turn 得到 include net == CodeForces 863D 題意:長度為 n 的數組 a[] ,有兩個操作: 1、區間 [l,r] 的數向右移,即 a[i+1] 變為 a[i],a[l] 變為 a[r] 。 2、
Codeforces 903G Yet Another Maxflow Problem - 線段樹
vector 維護 update win32 main spa 一個 tps print 題目傳送門 傳送門I 傳送門II 傳送門III 題目大意 給定一個網絡。網絡分為$A$,$B$兩個部分,每邊各有$n$個點。對於$A_{i} \ (1
CodeForces - 868F Yet Another Minimization Problem
|| inf -- efi min bits get 移動 個數 Description 給定一個長度為 \(n(n\le 10^5)\) 的數列,第 \(i\) 個數是 \(a_i\in[1,n]\) ,要求將其劃分為 \(k(2\le k\le min(20,n))\)
codeforces CF903G Yet Another Maxflow Problem 線段樹
img several http 答案 codeforce mes take 感謝 city $ \Rightarrow $ 戳我進CF原題 G. Yet Another Maxflow Problem time limit per test: 4 seconds mem
Codeforces 1073G Yet Another LCP Problem: 字尾陣列+單調棧
題意: 給定一個長度為 l e n
Codeforces 868F. Yet Another Minimization Problem【決策單調性優化DP】【分治】【莫隊】
LINK 題目大意 給你一個序列分成k段 每一段的代價是滿足\((a_i=a_j)\)的無序數對\((i,j)\)的個數 求最小的代價 思路 首先有一個暴力dp的思路是\(dp_{i,k}=min(dp_{j,k}+calc(j+1,i))\) 然後看看怎麼優化 證明一下這個DP的決策
Codeforces 1073G Yet Another LCP Problem $SA$+單調棧
題意 給出一個字串\(s\)和\(q\)個詢問。 每次詢問給出兩個長度分別為\(k,l\)的序列\(a\)和序列\(b\)。 求\(\sum_{i=1}^{k}\sum_{j=1}^{l}lcp(s[a_i…n],s[b_j…n])\) Solution \(SA\)練習題。 求出\(height\)陣
CodeForces 868F Yet Another Minimization Problem(決策單調性優化 + 分治)
efi isp size fine logs res namespace c++ 得到 題意 給定一個序列 \(\{a_1, a_2, \cdots, a_n\}\),要把它分成恰好 \(k\) 個連續子序列。 每個連續子序列的費用是其中相同元素的對數,求所有劃分中的費用之
CodeForces - 393E Yet Another Number Sequence
space 二項式定理 ever title #define lse size void hat Discription Everyone knows what the Fibonacci sequence is. This sequence can be defined
165C Another Problem on Strings (字首)
題目連結:http://codeforces.com/problemset/problem/165/C點選開啟連結 C. Another Problem on Strings tim
Codeforces 1114F Please, another Queries on Array? [線段樹,歐拉函數]
read online \n 要求 math == 函數 uil ORC Codeforces 洛谷:咕咕咕 CF少有的大數據結構題。 思路 考慮一些歐拉函數的性質: \[ \varphi(p)=p-1\\varphi(p^k)=p^{k-1}\times (p-1)=
Codeforces 713C Sonya and Problem Wihtout a Legend DP(經典)
題意:給出長度為n的序列a,op:將任意一個數增大/減小1. n<=3000,a[i]<=1e9,問使序列a嚴格遞增所需要的最少op次數 當a遞增時:a[i]<a[i+1] a[i
863D - Yet Another Array Queries Problem(思維)
for space std 答案 ostream sca set struct 思維 原題連接:http://codeforces.com/problemset/problem/863/D 題意:對a數列有兩種操作: 1 l r ,[l, r] 區間的數字滾動,即a[i
【CF903G】Yet Another Maxflow Problem 線段樹
pri soft string ace 題解 pda 容量 tro tor 【CF903G】Yet Another Maxflow Problem 題意:一張圖分為兩部分,左邊有n個點A,右邊有m個點B,所有Ai->Ai+1有邊,所有Bi->Bi+1有邊,某些
[CF903G]Yet Another Maxflow Problem
發的 void b+ std sdi 需要 -a lin clu [CF903G]Yet Another Maxflow Problem 題目大意: 有\(A\)類點和\(B\)類點各\(n(n\le2\times10^5)\)個,所有\(A_i\)到\(A_{i+1}\)
CodeForces - 524F And Yet Another Bracket Sequence
|| blank int 自動 要求 += com .... %s 題面在這裏! (會考完之後休閑休閑2333) 可以發現,如果把一個串中"()"自動刪除,最後剩的一定是形如"))))....))(((..((("這樣的串,然後我們多加進去的括號的個數就
CF868 F. Yet Another Minimization Problem 決策單調優化 分治
efi getch 預處理 algo 單調性 代碼 arr 最優決策 ref 題目鏈接 CF868F. Yet Another Minimization Problem 題解 \(f_{i,j}=\min\limits_{k=1}^{i}\{f_{k,j-1}+w_{k,i
CodeForces - 276E Little Girl and Problem on Trees(線段樹)
題意 現在給你一棵這樣的樹,除了根節點外,其他的所有節點度都為2,也就是說除了根節點之外其他的節點都只能有一個節點,現在有兩種操作: 1。以當前節點為中心,距離為d的範圍內的點全部都加上x。 2。查詢某個點的值 思路* 觀察這樣一張圖,你會發現他們其實都是一條一條的鏈狀的,所以對於更新