#include <bits/stdc++.h>
#pragma optimize("Ofast")
#pragma target("avx2")
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(s) (int)s.size()
#define y1 yy
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define in insert
#define int ll
const int MAX=1e4+5;
const int B=90;
const int N=105;
const int block=400;
const int maxB=MAX/B+10;
const ll inf=2e18;
const int mod=998244353;
const int mod1=1e9+9;
const ld eps=1e-9;
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,-1,1,-1};
int binpow(int a,int n){
if(!n)return 1;
if(n%2==1)return a*binpow(a,n-1)%mod;
int k=binpow(a,n/2);
return k*k%mod;
}
int dp[MAX][410];
int n,m,h;
int a[MAX][110];
int b[MAX][110];
void solve(){
cin>>n>>m>>h;
for(int i=1;i<n;i++){
for(int j=1;j<=h;j++){
cin>>a[i][j]>>b[i][j];
a[i][j]++;
}
}
dp[1][0]=1;
for(int i=1;i<n;i++){
for(int j=0;j<=m;j++){
if(j)dp[i][j]+=dp[i][j-1];
for(int k=1;k<=h;k++){
if(a[i][k]<=i||j+b[i][k]>m)continue;
dp[a[i][k]][j+b[i][k]]+=dp[i][j];
}
}
}
for(int i=0;i<m;i++){
cout<<dp[n][i]<<" ";
}
}
signed main(){
// freopen("help.in","r",stdin);
// freopen("help.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// prec();
int t=1;
// cin>>t;
while(t--)solve();
}
Compilation message
journey.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
3 | #pragma optimize("Ofast")
|
journey.cpp:4: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
4 | #pragma target("avx2")
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |