Submission #272065

#TimeUsernameProblemLanguageResultExecution timeMemory
272065AKaan37Lucky Numbers (RMI19_lucky)C++17
28 / 100
1046 ms2296 KiB
//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 (stderr)

lucky.cpp:57:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main(void){
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...