Submission #272830

#TimeUsernameProblemLanguageResultExecution timeMemory
272830EJOI2019AndrewRack (eJOI19_rack)C++14
40 / 100
1 ms288 KiB
#include<bits/stdc++.h> using namespace std; string ans; map<int,int>freq; long long int MOD=1000000007; void rack(long long int k) { if(k==1&&freq[k]>1) return; if(k%2) ans+='L'; else ans+='R'; int fn(0); if(k%2) fn=1; k/=2; k+=fn; ++freq[k]; rack(k); } long long int solve(long long int n) { long long int l(1),r(pow(2,n)); for(int i=0; i<ans.length(); ++i) { long long int mid=(l+r)/2; if(ans[i]=='R') l=mid+1; else r=mid-1; l%=MOD; r%=MOD; } return l; } int main() { long long int n,k; cin>>n>>k; rack(k); cout<<solve(n); return 0; }

Compilation message (stderr)

rack.cpp: In function 'long long int solve(long long int)':
rack.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 | for(int i=0; i<ans.length(); ++i)
      |              ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...