Submission #837270


Source Code Expand

Copy
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[SIZE];
int dp[5001][5001];
void ADD(int &x,int v){
    if(v>=MOD)v-=MOD;
    x+=v;
    if(x>=MOD)x-=MOD;
}
LL mypow(LL x,LL y){
    x%=MOD;
    LL res=1%MOD;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
int main(){
    DRI(N);
    RS(s);
    int len=LEN(s);
    dp[0][0]=1;
    REP(i,N){
        REP(j,N){
            if(!dp[i][j])continue;
            if(j)ADD(dp[i+1][j-1],dp[i][j]*(1+(j<=len)));
            else ADD(dp[i+1][j],dp[i][j]);
            if(j<len)ADD(dp[i+1][j+1],dp[i][j]);
            else ADD(dp[i+1][j+1],dp[i][j]*2);
        }
    }
    printf("%d\n",dp[N][len]);
    return 0;
}

Submission Info

Submission Time
Task F - Unhappy Hacking
User dreamoon
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1768 Byte
Status AC
Exec Time 371 ms
Memory 67072 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:48:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     DRI(N);
           ^
./Main.cpp:49:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     RS(s);
          ^

Judge Result

Set Name Sample Sub1 Sub2
Score / Max Score 0 / 0 400 / 400 400 / 400
Status
AC × 3
AC × 23
AC × 44
Set Name Test Cases
Sample 0_01, 0_02, 0_03
Sub1 0_01, 0_02, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20, 1_21, 1_22, 1_23, 1_24
Sub2 0_01, 0_02, 0_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20, 1_21, 1_22, 1_23, 1_24, 2_25, 2_26, 2_27, 2_28, 2_29, 2_30, 2_31, 2_32, 2_33, 2_34, 2_35, 2_36, 2_37, 2_38, 2_39, 2_40, 2_41, 2_42, 2_43, 2_44
Case Name Status Exec Time Memory
0_01 AC 4 ms 256 KB
0_02 AC 8 ms 1664 KB
0_03 AC 344 ms 67072 KB
1_04 AC 4 ms 256 KB
1_05 AC 8 ms 1664 KB
1_06 AC 8 ms 1664 KB
1_07 AC 8 ms 1664 KB
1_08 AC 8 ms 1664 KB
1_09 AC 8 ms 1664 KB
1_10 AC 8 ms 1664 KB
1_11 AC 8 ms 1664 KB
1_12 AC 8 ms 1664 KB
1_13 AC 8 ms 1664 KB
1_14 AC 10 ms 1664 KB
1_15 AC 8 ms 1664 KB
1_16 AC 8 ms 1664 KB
1_17 AC 8 ms 1536 KB
1_18 AC 8 ms 1536 KB
1_19 AC 8 ms 1536 KB
1_20 AC 5 ms 512 KB
1_21 AC 6 ms 1152 KB
1_22 AC 5 ms 512 KB
1_23 AC 8 ms 1536 KB
1_24 AC 7 ms 1280 KB
2_25 AC 345 ms 67072 KB
2_26 AC 345 ms 67072 KB
2_27 AC 338 ms 67072 KB
2_28 AC 334 ms 67072 KB
2_29 AC 335 ms 67072 KB
2_30 AC 340 ms 67072 KB
2_31 AC 363 ms 67072 KB
2_32 AC 343 ms 67072 KB
2_33 AC 335 ms 67072 KB
2_34 AC 363 ms 67072 KB
2_35 AC 336 ms 66944 KB
2_36 AC 333 ms 66944 KB
2_37 AC 362 ms 66944 KB
2_38 AC 371 ms 66944 KB
2_39 AC 336 ms 66944 KB
2_40 AC 277 ms 56192 KB
2_41 AC 159 ms 32768 KB
2_42 AC 322 ms 64512 KB
2_43 AC 195 ms 39680 KB
2_44 AC 15 ms 3584 KB