From 211c7ea96be7bb7f13ca2a0a119c8bb86bcd30de Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Fri, 22 Nov 2024 17:09:56 +0800 Subject: [PATCH] update --- src/P3383/P3383.cpp | 52 ++++++++++++++++++ src/P8865/P8865.cpp | 110 +++++++++++++++++++++++++++++++++++++ src/P8865/plant/plant1.ans | 1 + src/P8865/plant/plant1.in | 6 ++ src/P8865/plant/plant2.ans | 1 + src/P8865/plant/plant2.in | 8 +++ src/P8865/plant/plant3.ans | 1 + src/P8865/plant/plant3.in | 18 ++++++ 8 files changed, 197 insertions(+) create mode 100644 src/P3383/P3383.cpp create mode 100644 src/P8865/P8865.cpp create mode 100644 src/P8865/plant/plant1.ans create mode 100644 src/P8865/plant/plant1.in create mode 100644 src/P8865/plant/plant2.ans create mode 100644 src/P8865/plant/plant2.in create mode 100644 src/P8865/plant/plant3.ans create mode 100644 src/P8865/plant/plant3.in diff --git a/src/P3383/P3383.cpp b/src/P3383/P3383.cpp new file mode 100644 index 0000000..a7601c5 --- /dev/null +++ b/src/P3383/P3383.cpp @@ -0,0 +1,52 @@ +#include +using namespace std; +using ll = int64_t; + +const ll maxn{ll(1e8+5)}; +ll n,q,tot,ans[maxn]; +bitset f; + +void init(){ + for(ll i{2};i<=n;i++){ + if(!f[i]){ + for(ll j{i+i};j<=n;j+=i){ + f[j]=1; + } + } + } +} + +struct CinNum{ + char c; + ll n; + CinNum &operator>>(ll &num){ + c=n=0; + while(!isdigit(c)){ + c=getchar(); + } + while(isdigit(c)){ + n=n*10+c-'0'; + c=getchar(); + } + num=n; + return *this; + } +}cinn; + +#define cin cinn + +int main(){ + iostream::sync_with_stdio(0)/*,cin.tie(0)*/,cout.tie(0); + cin>>n>>q; + init(); + for(ll i{2};i<=n;i++){ + if(!f[i]){ + ans[++tot]=i; + } + } + while(q--){ + ll k; + cin>>k; + cout< +using namespace std; +using ll = int64_t; + +const ll maxn{ll(1e3+5)}, mod{998244353}; +ll t,id,n,m,c,f,tmp,tor[maxn][maxn],totc,tou[maxn][maxn],ptor[maxn][maxn],totf,tod[maxn][maxn]; +bitset g[maxn]; +string s; + +template +void pt(Args&&...args){ + ((cout<(args)<<' '),...); + cout<<'\n'; +} + +template +ostream&operator<<(ostream &os,const pair &p){ + cout<<"[DEBUG] "<<"( "<>t>>id; + while(t--){ + cin>>n>>m>>c>>f; + totc=0; + totf=0; + // pt(n,m,c,f); + for(ll i{1};i<=n;i++){ + cin>>s; + for(ll j{1};j<=m;j++){ + g[i][j]=s[j-1]-'0'; + // pt(g[i][j]); + } + } + + // look right + for(ll i{1};i<=n;i++){ + tor[i][m+1]=0; + for(ll j{m};j>=0;j--){ + if(g[i][j]){ + tor[i][j]=0; + ptor[i][j]=0; + }else{ + tor[i][j]=tor[i][j+1]+1; + ptor[i][j]=ptor[i-1][j]+max(ll(0),tor[i][j]-1); + } + } + } + // pnm(tor); + // pnm(ptor); + + //look up + for(ll j{1};j<=m;j++){ + tou[0][j]=0; + for(ll i{1};i<=n;i++){ + if(g[i][j]){ + tou[i][j]=0; + }else{ + tou[i][j]=tou[i-1][j]+1; + } + } + } + // pnm(tou); + + //look down + for(ll j{1};j<=m;j++){ + tod[n+1][j]=0; + } + for(ll i{n};i>=0;i--){ + for(ll j{1};j<=m;j++){ + if(g[i][j]){ + tod[i][j]=0; + }else{ + tod[i][j]=tod[i+1][j]+1; + } + } + } + // pnm(tod); + + for(ll j{1};j=2&&tou[i][j]>=3 + ){ + // cout<0){ + totf = (totf+(ptor[i-1][j]*(tor[i][j]-1)*(tod[i][j]-1))%mod)%mod; + } + // pt(totc,totf); + } + } + } + cout<