Submission #337510

# Submission time Handle Problem Language Result Execution time Memory
337510 2020-12-21T03:18:37 Z beksultan04 Energetic turtle (IZhO11_turtle) C++14
40 / 100
2000 ms 262148 KB
#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 = 1e6+12,INF=1e9+7;
int dp[2000][2000][30],q[2000][2000];

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)
        q[x][y]=1;
    }

        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][j+1][l-q[i][j]] += dp[i][j][l];

                dp[i+1][j][l-q[i][j]] += dp[i][j][l];
                dp[i][j+1][l-q[i][j]] %= mod;

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

Compilation message

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 time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 2 ms 1900 KB Output is correct
5 Correct 11 ms 8172 KB Output is correct
6 Correct 48 ms 61804 KB Output is correct
7 Correct 109 ms 98580 KB Output is correct
8 Correct 194 ms 240492 KB Output is correct
9 Runtime error 388 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 648 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Execution timed out 2092 ms 93676 KB Time limit exceeded
12 Execution timed out 2086 ms 96108 KB Time limit exceeded
13 Execution timed out 2067 ms 127288 KB Time limit exceeded
14 Execution timed out 2085 ms 99132 KB Time limit exceeded
15 Execution timed out 2089 ms 67308 KB Time limit exceeded
16 Execution timed out 2093 ms 128064 KB Time limit exceeded
17 Runtime error 1865 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Execution timed out 2092 ms 118276 KB Time limit exceeded
19 Execution timed out 2084 ms 104008 KB Time limit exceeded
20 Execution timed out 2053 ms 86560 KB Time limit exceeded