Submission #6578693


Source Code Expand

Copy
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
string s;
LL dp[100000+10][13];
const int MOD=1e9+7;
int cont[13]={0,4,8,12,3,7,11,2,6,10,1,5,9};
int main(){
	dp[0][0]=1;
	cin>>s;
	int len=s.length();
//	int flag=0;
//	rb(i,0,len-1){
//		if(s[i]=='?'){
//			flag=1;
//		}
//	}
//	if(flag==0){
//		puts("0");
//		return 0;
////	}
//	if(len==1){
//		puts("1");
//		return 0;
//	}
	rb(i,1,len){
		rb(j,0,12){
		if(s[i-1]=='?'){
			if(i==1){
				if(j<10)
				dp[i][j]=1;
				continue;
			}
			rb(k,0,9){
				int las=j-k;
				if(las<0) las+=13;
				dp[i][j]+=dp[i-1][cont[las]];
				dp[i][j]%=MOD;
//				cout<<dp[i][j]<<" "<<j<<" "<<cont[las]<<endl;
			}
		}
		else{
			int las=j-(s[i-1]-'0');
			if(las<0) las+=13;
			if(i==1){
				dp[i][s[i-1]-'0']=1;
				break;
			}
			dp[i][j]=dp[i-1][cont[las]];
		}
//		cout<<i<<","<<j<<dp[i][j]<<"   ";	
		}
//		cout<<endl;
	}
//	rb(i,1,len){
//		rb(j,0,12){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	printf("%I64d\n",dp[len][5]);
	return 0;
}

Submission Info

Submission Time
Task D - Digits Parade
User Gary
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1492 Byte
Status AC
Exec Time 53 ms
Memory 10624 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:75:29: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
  printf("%I64d\n",dp[len][5]);
                             ^

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
sub1_01.txt AC 16 ms 4480 KB
sub1_02.txt AC 21 ms 6528 KB
sub1_03.txt AC 1 ms 256 KB
sub1_04.txt AC 1 ms 256 KB
sub1_05.txt AC 18 ms 6528 KB
sub1_06.txt AC 1 ms 256 KB
sub1_07.txt AC 1 ms 512 KB
sub1_08.txt AC 11 ms 8832 KB
sub1_09.txt AC 42 ms 8960 KB
sub1_10.txt AC 28 ms 6528 KB
sub1_11.txt AC 1 ms 256 KB
sub1_12.txt AC 1 ms 256 KB
sub1_13.txt AC 1 ms 256 KB
sub1_14.txt AC 1 ms 256 KB
sub1_15.txt AC 1 ms 256 KB
sub1_16.txt AC 1 ms 256 KB
sub1_17.txt AC 53 ms 10624 KB
sub1_18.txt AC 20 ms 10624 KB
sub1_19.txt AC 37 ms 10624 KB
sub1_20.txt AC 37 ms 10624 KB
sub1_21.txt AC 10 ms 10624 KB
sub1_22.txt AC 10 ms 10624 KB
sub1_23.txt AC 10 ms 10624 KB
sub1_24.txt AC 36 ms 10624 KB
sub1_25.txt AC 1 ms 256 KB
sub1_26.txt AC 1 ms 256 KB