This commit is contained in:
Zengtudor 2024-11-21 23:36:58 +08:00
parent 2dff97c92c
commit 2ea60ba602
3 changed files with 112 additions and 0 deletions

28
src/P1002/P1002.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll maxn{ll(20+5)};
ll mx,my,bx,by;
ll dp[maxn][maxn];
int main(){
iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>bx>>by>>mx>>my;
mx+=1;
my+=1;
dp[0][1]=1;
for(ll i{1};i<=bx+1;i++){
for(ll j{1};j<=by+1;j++){
if(
(i==mx-1&&(j==my-2||j==my+2))||
(i==mx-2&&(j==my-1||j==my+1))||
(i==mx+1&&(j==my-2||j==my+2))||
(i==mx+2&&(j==my+1||j==my-1))
||(i==mx&&j==my)
){
continue;
}
dp[i][j]=dp[i-1][j]+dp[i][j-1];
}
}
cout<<dp[bx+1][by+1]<<'\n';
}

28
src/P1176/P1176.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll maxn{1000+5},mod{100003};
ll m,n,dp[maxn][maxn];
bitset<maxn> obs[maxn];
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
for(ll i{1};i<=m;i++){
ll x,y;
cin>>x>>y;
obs[x][y]=true;
}
obs[1][1]=true;
dp[1][1]=1;
for(ll i{1};i<=n;i++){
for(ll j{1};j<=n;j++){
if(obs[i][j]){
continue;
}
dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
}
}
cout<<dp[n][n]<<'\n';
}

56
src/P7077/P7077.cpp Normal file
View File

@ -0,0 +1,56 @@
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll maxn{ll(1e5+5)}, mod{998244353};
ll n,a[maxn],m,t[maxn],p[maxn],v[maxn],q;
vector<ll> e[maxn];
void dfs(ll const &f){
if(t[f]==1){
a[p[f]]=(a[p[f]]+v[f])%mod;
}else if(t[f]==2){
for(ll j{1};j<=n;j++){
a[j]=(a[j]*v[f])%mod;
}
}else{
for(auto const&i:e[f]){
dfs(i);
}
}
}
int main(){
iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(ll i{1};i<=n;i++){
cin>>a[i];
}
cin>>m;
for(ll i{1};i<=m;i++){
cin>>t[i];
if(t[i]==1){
cin>>p[i]>>v[i];
}else if(t[i]==2){
cin>>v[i];
}else{
ll c;
cin>>c;
while(c--){
ll f;
cin>>f;
e[i].emplace_back(f);
}
}
}
cin>>q;
for(ll i{1};i<=q;i++){
ll f;
cin>>f;
dfs(f);
}
for(ll i{1};i<=n;i++){
cout<<a[i]<<' ';
}
cout<<'\n';
}