diff --git a/src/10/27/P9753.cpp b/src/10/27/P9753.cpp new file mode 100644 index 0000000..85b1b28 --- /dev/null +++ b/src/10/27/P9753.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include +using ll = int64_t; + +ll n,ans; +std::string s; +const ll maxn = 2e6+5; +ll dp[maxn],end[maxn]; + +int main(){ + std::iostream::sync_with_stdio(false); + std::cin.tie(nullptr); + + std::cin>>n; + std::cin>>s; + s='\0'+s; + struct S{ + ll num,pos,ans; + }; + std::stack stk; + for(ll i=1;i<=n;i++){ + if(stk.size() && stk.top().num==s[i]){ + if(stk.size()==1){ + end[i]+=end[stk.top().pos-1]*(ans-stk.top().ans); + ans+=end[i]; + } + ans+=1; + end[i]=ans; + stk.pop(); + }else{ + stk.emplace(s[i],i,ans); + } + printf("i=%lld, ans=%lld, end=%lld\n",i,ans,end[i]); + } + std::cout< +#include +#include +#include +#include +using ll = int64_t; + +const ll maxn=2e6+5; +ll n,a[maxn],sc[maxn],si[maxn],dp[maxn]; + +#define printf + +static inline void solve(){ + std::cin>>n; + for(ll i=0;i>a[i]; + sc[i]=sc[i-1]+(a[i]==a[i-1]?a[i]:0); + printf("sc[%lld]=%lld\n",i,sc[i]); + } + for(ll j=1;j<=n;j++){ + const ll i=si[a[j]]; + dp[j]=dp[j-1]; + if(i>0){ + dp[j]=std::max( + dp[i+1]+(sc[j]-sc[i+1])/* 为什么这里不能是sc[j-1]-sc[i+1] */+a[j], + dp[j] + ); + } + printf("i=%lld, dp[%lld]=%lld\n",i,j,dp[j]); + si[a[j]]=j; + } + std::cout<>T; + while(T--)solve(); +} \ No newline at end of file diff --git a/src/7/28/P11233.cpp b/src/7/28/P11233.cpp deleted file mode 100644 index 294989d..0000000 --- a/src/7/28/P11233.cpp +++ /dev/null @@ -1,3 +0,0 @@ -int main(){ - -} \ No newline at end of file