Submission #1041641

# Submission time Handle Problem Language Result Execution time Memory
1041641 2024-08-02T06:41:09 Z vjudge1 Ljetopica (COI19_ljetopica) C++17
8 / 100
1 ms 604 KB
#include <iostream>
#include <vector>

using namespace std;
const int N = 1e5 + 10;
int tp[N], mod = 1e9 + 7;

// void solve1(int n, int k){
// 	string s;
// 	cin>>s;
// }

int main(){
	tp[0] = 1;
	for (int i=1;i<N;i++)
		tp[i] = (tp[i-1] + tp[i-1]) % mod;

	int n, k;
	cin>>n>>k;

	// if (n <= 25)
	// 	solve1(n, k);

	string s, l, r, p1 = "1", p2 = "1";
	cin>>s>>l>>r;

	while (l.size() < n)
		l = '0' + l;
	while (r.size() < n)
		r = '0' + r;

	for (int i=0;i<n-1;i++){
		if (s[i] == 'L')
			p1 += '0', p2 += '1';
		else
			p1 += '1', p2 += '0';
	}

	int Ans = 0;
	for (auto i : {p1, p2}){
		if (i > r or i < l)
			continue;
		for (int j=0;j<i.size();j++)
			if (i[j] == '1')
				Ans = (Ans + tp[i.size() - 1 - j]) % mod;
	}
	cout<<Ans<<'\n';

}

Compilation message

ljetopica.cpp: In function 'int main()':
ljetopica.cpp:27:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |  while (l.size() < n)
      |         ~~~~~~~~~^~~
ljetopica.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |  while (r.size() < n)
      |         ~~~~~~~~~^~~
ljetopica.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int j=0;j<i.size();j++)
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Incorrect 1 ms 604 KB Output isn't correct
10 Halted 0 ms 0 KB -