Submission #1530071


Source Code Expand

Copy
#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	string s[2];
	cin >> s[0] >> s[1];
	int pre = s[0][0] != s[1][0];
	int64_t ans = 3 * (pre + 1), mod = 1e9 + 7;
	for(int i = 1 + pre, now; i < n; i += now + 1, pre = now){
		now = s[0][i] != s[1][i];
		if(pre && now) ans *= 3;
		else if(pre) ans *= 1;
		else if(now) ans *= 2;
		else ans *= 2;
		ans %= mod;
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - Coloring Dominoes
User jbyxm
Language C++14 (GCC 5.4.1)
Score 400
Code Size 426 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 400 / 400 sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt 1 ms 256 KB
10.txt 1 ms 256 KB
11.txt 1 ms 256 KB
12.txt 1 ms 256 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 1 ms 256 KB
16.txt 1 ms 256 KB
17.txt 1 ms 256 KB
18.txt 1 ms 256 KB
19.txt 1 ms 256 KB
2.txt 1 ms 256 KB
20.txt 1 ms 256 KB
21.txt 1 ms 256 KB
22.txt 1 ms 256 KB
3.txt 1 ms 256 KB
4.txt 1 ms 256 KB
5.txt 1 ms 256 KB
6.txt 1 ms 256 KB
7.txt 1 ms 256 KB
8.txt 1 ms 256 KB
9.txt 1 ms 256 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB
sample3.txt 1 ms 256 KB