Submission #147628

#TimeUsernameProblemLanguageResultExecution timeMemory
147628JovanK26Ljetopica (COI19_ljetopica)C++14
0 / 100
1072 ms4908 KiB
#include <iostream> using namespace std; long long n,k; string path; string a; string b; long long aval=0; long long bval=0; long long rez=0; bool vis[1000000007]; void solve(long long start,long long k,long long n,bool chk) { if(n==path.size()) { if(!vis[start] && start>=aval && start<=bval) { rez+=start; rez%=1000000007; vis[start]=1; //cout << start << endl; } return; } if(k==0) { if(!chk) { if(path[n]=='L')solve(2*start,k,n+1,chk); else { solve(2*start+1,k,n+1,chk); } } else { if(path[n]=='R')solve(2*start,k,n+1,chk); else { solve(2*start+1,k,n+1,chk); } } } else { if(!chk) { solve(2*start,k,n+1,chk); solve(2*start+1,k-1,n+1,chk^1); } else { solve(2*start+1,k,n+1,chk); solve(2*start,k-1,n+1,chk^1); } } } int main() { cin >> n >> k; cin >> path; cin >> a; cin >> b; long long br=0; for(long long i=a.size()-1;i>=0;i--) { if(a[i]=='1')aval+=(1<<br); br++; } br=0; for(long long i=b.size()-1;i>=0;i--) { if(b[i]=='1')bval+=(1<<br); br++; } solve(1,k,0,0); solve(1,k,0,1); cout << rez; return 0; }

Compilation message (stderr)

ljetopica.cpp: In function 'void solve(long long int, long long int, long long int, bool)':
ljetopica.cpp:14:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(n==path.size())
        ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...