Submission #853916
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second const ll mod=1e9+7; int n,S; string s; ll dp[301][301][301]; ll dfs(int now, int len, int cor) { if(dp[now][len][cor]>=0) return dp[now][len][cor]; if(now==n) { if(len==S && cor==S) return 1; else return 0; } ll ret=0; if(len==cor) { if(cor==S) (ret+=2*dfs(now+1, len+1, cor))%=mod; else { (ret+=dfs(now+1, len+1, cor+1))%=mod; (ret+=dfs(now+1, len+1, cor))%=mod; } //削除 (ret+=dfs(now+1, max(0,len-1), max(0,cor-1)))%=mod; } else { (ret+=2*dfs(now+1, len+1, cor))%=mod; //削除 (ret+=dfs(now+1, max(0,len-1), cor))%=mod; } return dp[now][len][cor]=ret; } int main() { cin >>n >>s; S=s.size(); memset(dp,-1,sizeof(dp)); cout << dfs(0,0,0) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Unhappy Hacking |
User | imulan |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1205 Byte |
Status | RE |
Exec Time | 548 ms |
Memory | 213376 KB |
Judge Result
Set Name | Sample | Sub1 | Sub2 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | 0 / 400 | ||||||||||
Status |
|
|
|
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 | 343 ms | 213248 KB |
0_02 | AC | 359 ms | 213248 KB |
0_03 | RE | 531 ms | 213248 KB |
1_04 | AC | 342 ms | 213248 KB |
1_05 | AC | 347 ms | 213376 KB |
1_06 | AC | 352 ms | 213376 KB |
1_07 | AC | 520 ms | 213248 KB |
1_08 | AC | 548 ms | 213376 KB |
1_09 | AC | 542 ms | 213376 KB |
1_10 | AC | 544 ms | 213376 KB |
1_11 | AC | 386 ms | 213376 KB |
1_12 | AC | 541 ms | 213376 KB |
1_13 | AC | 536 ms | 213376 KB |
1_14 | AC | 531 ms | 213376 KB |
1_15 | AC | 376 ms | 213376 KB |
1_16 | AC | 541 ms | 213376 KB |
1_17 | AC | 439 ms | 213376 KB |
1_18 | AC | 519 ms | 213376 KB |
1_19 | AC | 438 ms | 213376 KB |
1_20 | AC | 346 ms | 213248 KB |
1_21 | AC | 385 ms | 213248 KB |
1_22 | AC | 347 ms | 213248 KB |
1_23 | AC | 509 ms | 213376 KB |
1_24 | AC | 448 ms | 213248 KB |
2_25 | RE | 532 ms | 213248 KB |
2_26 | RE | 531 ms | 213248 KB |
2_27 | RE | 531 ms | 213376 KB |
2_28 | RE | 536 ms | 213376 KB |
2_29 | RE | 532 ms | 213376 KB |
2_30 | RE | 529 ms | 213248 KB |
2_31 | RE | 527 ms | 213376 KB |
2_32 | RE | 532 ms | 213248 KB |
2_33 | RE | 535 ms | 213376 KB |
2_34 | RE | 529 ms | 213376 KB |
2_35 | RE | 534 ms | 213376 KB |
2_36 | RE | 533 ms | 213376 KB |
2_37 | RE | 533 ms | 213376 KB |
2_38 | RE | 535 ms | 213376 KB |
2_39 | RE | 534 ms | 213376 KB |
2_40 | RE | 531 ms | 213376 KB |
2_41 | RE | 534 ms | 213248 KB |
2_42 | RE | 533 ms | 213376 KB |
2_43 | RE | 530 ms | 213248 KB |
2_44 | RE | 532 ms | 213248 KB |