Submission #337561

#TimeUsernameProblemLanguageResultExecution timeMemory
337561beksultan04Energetic turtle (IZhO11_turtle)C++14
30 / 100
2104 ms155464 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 3e5+12,INF=1e9+7;
int dp[4][N][21];
vector <int> v[N];
main(){
    int n,m,i,j,k,l,t,mod,ans=0;
    scan3(n,m,k)
    scan2(t,mod)
    while (k--){
        int x,y;
        scan2(x,y)
        v[x].pb(y);
    }

    dp[0][0][t]=1;
    for (i=0;i<=n;++i){
        for (j=0;j<=m;++j){
            for (l=0;l<=t;++l){
                dp[i%3][j+1][l] += dp[i%3][j][l];
                dp[(i+1)%3][j][l] = dp[i%3][j][l];
                dp[i%3][j+1][l] %= mod;
                dp[(i+1)%3][j][l] %= mod;
            }
        }
    }
    for (l=0;l<=t;++l){
        ans+=dp[n%3][m][l];
        ans%=mod;
    }
    cout <<ans;
}

Compilation message (stderr)

turtle.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      |      ^
turtle.cpp: In function 'int main()':
turtle.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
turtle.cpp:24:5: note: in expansion of macro 'scan3'
   24 |     scan3(n,m,k)
      |     ^~~~~
turtle.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
turtle.cpp:25:5: note: in expansion of macro 'scan2'
   25 |     scan2(t,mod)
      |     ^~~~~
turtle.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
turtle.cpp:28:9: note: in expansion of macro 'scan2'
   28 |         scan2(x,y)
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...