Submission #145542

#TimeUsernameProblemLanguageResultExecution timeMemory
145542Ok_googleLjetopica (COI19_ljetopica)C++17
8 / 100
3 ms376 KiB
#include<bits/stdc++.h> #define pb push_back #define fr first #define sc second #define ll long long using namespace std; const int mnx = 1e6 + 5; const int mod = 1e9 + 7; ll n, k; string s; string a, b; bool gon(string a, string b){ if(a.size() > b.size()) return 1; if(a.size() < b.size()) return 0; for(int i = 1; i <= a.size(); i++){ if(a[i] > b[i]) return 1; if(a[i] < b[i]) return 0; } return 1; } string x, y; string mkd(string a, string b){ string c; for(int i = 0; i <= a.size(); i++){ c += '0'; } for(int i = a.size() - 1; i >= 0; i--){ c[i + 1] = c[i + 1] + a[i] + b[i] - '0' - '0'; if(c[i + 1] >= '2'){ c[i + 1] -= 2; c[i] += 1; } } return c; } ll asd(string s){ ll k = 1; ll sum = 0; for(int i = s.size() - 1; i >= 0; i--){ if(s[i] == '1'){ sum += k; sum %= mod; } k *= 2; k %= mod; } return sum; } int main(){ cin >> n >> k; cin >> s; cin >> a >> b; if(k != 0){ cout << 0 << '\n'; return 0; } x = "1"; y = "1"; for(int i = 0; i < s.size(); i++){ x += (s[i] == 'R') + '0'; y += (s[i] == 'L') + '0'; } bool ok = 0; bool ko = 0; if(gon(b, x) && gon(x, a)){ ok = 1; } if(gon(b, y) && gon(y, a)){ ko = 1; } string f, z; if(ok && ko){ z = mkd(x, y); } if(ok && !ko){ z = x; } if(!ok && ko){ z = y; } cout << asd(z) << '\n'; return 0; }

Compilation message (stderr)

ljetopica.cpp: In function 'bool gon(std::__cxx11::string, std::__cxx11::string)':
ljetopica.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i <= a.size(); i++){
                 ~~^~~~~~~~~~~
ljetopica.cpp: In function 'std::__cxx11::string mkd(std::__cxx11::string, std::__cxx11::string)':
ljetopica.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i <= a.size(); i++){
                 ~~^~~~~~~~~~~
ljetopica.cpp: In function 'int main()':
ljetopica.cpp:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size(); i++){
                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...