답안 #272065

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
272065 2020-08-18T08:33:18 Z AKaan37 Lucky Numbers (RMI19_lucky) C++17
28 / 100
200 ms 2296 KB
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 10003;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li][4][4];
int cev;
string s;
vector<int> v;

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int f(int sira,int kucuk,int bir){
	int cevv=0;
	if(sira==n)return 1;
	if(~dp[sira][kucuk][bir])return dp[sira][kucuk][bir];
	for(int i=0;i<=s[sira]-'0';i++){
		if(bir && i==3)continue;
		cevv=add(cevv,f(sira+1,(i<s[sira]-'0'?1:kucuk),(i==1?1:0)));
	}
	if(kucuk){
		for(int i=s[sira]-'0'+1;i<=9;i++){
			if(bir && i==3)continue;
			cevv=add(cevv,f(sira+1,(i<s[sira]-'0'?1:kucuk),(i==1?1:0)));
		}
	}
	return dp[sira][kucuk][bir]=cevv;
}

main(void){
	//~ fio();
	//~ freopen("at.txt","r",stdin);
	//~ freopen("att.txt","w",stdout);
	memset(dp,-1,sizeof(dp));
	cin>>n>>t;
	cin>>s;
	cout<<f(0,0,0)<<endl;
	while(t--){
		int x,y,z;
		cin>>z>>x>>y;
		n=y;
		for(int i=0;i<n;i++){
			dp[i][0][0]=-1;
			dp[i][0][1]=-1;
			dp[i][1][1]=-1;
			dp[i][0][1]=-1;
		}
		cout<<f(x-1,0,0)<<endl;
	}
	return 0;
}

Compilation message

lucky.cpp:57:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main(void){
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 2 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1046 ms 2296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1046 ms 2296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 2 ms 1536 KB Output is correct
7 Execution timed out 1046 ms 2296 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 2 ms 1536 KB Output is correct
7 Execution timed out 1046 ms 2296 KB Time limit exceeded
8 Halted 0 ms 0 KB -