From 7f71412d4e43101a5d3d246a0068205b8e6908e5 Mon Sep 17 00:00:00 2001 From: kenny Date: Sun, 12 Sep 2021 10:30:29 +0800 Subject: [PATCH] tcirc APCS --- tcirc/d029.cpp | 30 +++++++++++++++++++++++++++++ tcirc/d030.cpp | 39 +++++++++++++++++++++++++++++++++++++ tcirc/d082.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ tcirc/d094.cpp | 37 +++++++++++++++++++++++++++++++++++ tcirc/d105.cpp | 37 +++++++++++++++++++++++++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 tcirc/d029.cpp create mode 100644 tcirc/d030.cpp create mode 100644 tcirc/d082.cpp create mode 100644 tcirc/d094.cpp create mode 100644 tcirc/d105.cpp diff --git a/tcirc/d029.cpp b/tcirc/d029.cpp new file mode 100644 index 0000000..5007140 --- /dev/null +++ b/tcirc/d029.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); +#define pii pair +#define F first +#define S second +#define ll long long +using namespace std; +int const N=2e5+10,INF=8e7; +int n; +int a[N],b[N]; +int main(){ + Hirasawa_Yui_My_Wife + cin>>n; + for(int i=0;i>a[i]; + for(int i=0;i>b[i]; + set st; + st.insert({INF,-1}); + ll ans=0; + for(int i=0;iS-1; + while(!st.empty()&&st.begin()->F<=a[i])st.erase(st.begin()); + st.insert({a[i],i}); + } + cout< +#include +#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); +using namespace std; +int const N=1e5+10,INF=8e7*2.5e1; +int n,l; +int c[N],h[N]; +int main(){ + Hirasawa_Yui_My_Wife + cin>>n>>l; + for(int i=1;i<=n;++i)cin>>c[i]; + for(int i=1;i<=n;++i)cin>>h[i]; + c[0]=0; + c[n+1]=l; + h[0]=h[n+1]=INF; + stack stk; + stk.push(0); + int tot=0,mx=-INF; + for(int i=1;i<=n;++i){ + while(c[stk.top()]+h[stk.top()]<=c[i]){ + mx=max(mx,h[stk.top()]); + ++tot; + stk.pop(); + } + if(c[stk.top()]<=c[i]-h[i]||c[i]+h[i]<=c[i+1]){//tree i fell + mx=max(mx,h[i]); + ++tot; + }else{ + stk.push(i); + } + } + while(c[stk.top()]+h[stk.top()] +#include +#define INF 80000000 +#define ll long long +#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); +using namespace std; +int const N=30+5; +int n,m; +int a[N][N],dp[N][N][N][N];//dp[i][j][k][l]:=start at [i][j], (k+1)*(l+1) size +int xc[N][N],yc[N][N];//xc[i][j]:=number of 0s in prefix along x-axis ends at [i][j] +int mod(int to,int z){ + return min(z,to-z); +} +int main(){ + Hirasawa_Yui_My_Wife + cin>>n>>m; + for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)cin>>a[i][j]; + for(int x=1;x<=n;++x){ + yc[x][0]=0; + yc[x][1]=(a[x][1]==0); + for(int y=2;y<=m;++y){ + yc[x][y]=yc[x][y-1]+(a[x][y]==0); + } + } + for(int y=1;y<=m;++y){ + xc[0][y]=0; + xc[1][y]=(a[1][y]==0); + for(int x=2;x<=n;++x){ + xc[x][y]=xc[x-1][y]+(a[x][y]==0); + } + } + memset(dp,0,sizeof(dp)); + for(int dx=1;dx +#include +#include +#include +#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); +#define pii pair +#define F first +#define S second +using namespace std; +int const N=1e6+10; +int n,p,l,r,nxt[N]; +bool vis[N]; +int main(){ + Hirasawa_Yui_My_Wife + cin>>n>>p>>l>>r; + for(int i=0;i>nxt[i]; + memset(vis,0,sizeof(vis)); + vis[0]=1; + queue que; + que.push({0,0}); + int ans=-1; + while(!que.empty()){ + pii cur=que.front(); + if(cur.F==p){ans=cur.S;break;} + if(cur.F+r +#include +#define ll long long +#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); +using namespace std; +int const N=1e5+10,M=1e2+3; +int n,m; +int w[2*N],op[M],l[N],r[N]; +void build(int cur){ + if(cur>=n)return; + build(l[cur]); + build(r[cur]); + w[cur]=w[l[cur]]+w[r[cur]]; +} +int put(int o){ + int cur=1; + while(cur>n>>m; + for(int i=n;i<2*n;++i)cin>>w[i]; + for(int i=0;i>op[i]; + int q,s,t; + for(int i=0;i>q>>s>>t,l[q]=s,r[q]=t; + build(1); + for(int i=0;i