Submission #1041621

#TimeUsernameProblemLanguageResultExecution timeMemory
1041621vjudge1Ljetopica (COI19_ljetopica)C++17
8 / 100
1 ms348 KiB
#include<bits/stdc++.h>

using namespace std;

const int mod = 1'000'000'007;
int N, K;
string s, a, b;

bool small(string a, string b)
{
  for(int i = 0; i < a.size(); i++)
    if(a[i] != b[i])
      return a[i] < b[i];
  return false;
}

int val(string s)
{
  int hsh = 0;
  for(char i : s)
    hsh = (hsh * 2ll + (i - '0')) % mod;
  return hsh;
}

void subtask1()
{
  string ans1 = "1", ans2 = "1";
  for(char i : s)
    {
      if(i == 'L')
	ans1 += '0', ans2 += '1';
      else
	ans1 += '1', ans2 += '0';
    }

  int ans = 0;

  if(!small(ans1, a) && !small(b, ans1))
    ans = (ans + val(ans1)) % mod;
  if(!small(ans2, a) && !small(b, ans2))
    ans = (ans + val(ans2)) % mod;
  cout << ans << endl;
  exit(0);
}

void subtask2()
{
}
int main()
{

  cin >> N >> K >> s >> a >> b;
  if(K == 0)
    subtask1();
  subtask2();
  return 0;
}

Compilation message (stderr)

ljetopica.cpp: In function 'bool small(std::string, std::string)':
ljetopica.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   for(int i = 0; i < a.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...