Submission #1608674
Source Code Expand
#include <iostream> #include <string> #include <algorithm> #include <math.h> #include <set> #include <string> #include <vector> #include <array> #include <stdlib.h> #define INT_MAX 2000000000 #define MOD 1000000007 #define ll long long #define REP(i,a,b) for(i = (a); i < (b); i++) #define rep(i,n) REP(i,0,n) #define bitget(a,b) (((a) >> (b)) & 1) using namespace std; int i, j, k; int main() { int n; string s1, s2; cin >> n; cin >> s1 >> s2; ll int ans = 1; int flag = 0; if (s1[0] == s2[0]) { ans = 3; flag = 0; } else { ans = 6; flag = 1; } REP(i, flag + 1, n) { if (s1[i] == s2[i]) { if (flag == 0) { ans = ans * 2 % MOD; } flag = 0; } else { if (flag == 0) { ans = ans * 2 % MOD; } else { ans = ans * 3 % MOD; } flag = 1; i++; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Coloring Dominoes |
User | noshi91 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 899 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | 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 | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 1 ms | 256 KB |
17.txt | AC | 1 ms | 256 KB |
18.txt | AC | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
2.txt | AC | 1 ms | 256 KB |
20.txt | AC | 1 ms | 256 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 1 ms | 256 KB |
3.txt | AC | 1 ms | 256 KB |
4.txt | AC | 1 ms | 256 KB |
5.txt | AC | 1 ms | 256 KB |
6.txt | AC | 1 ms | 256 KB |
7.txt | AC | 1 ms | 256 KB |
8.txt | AC | 1 ms | 256 KB |
9.txt | AC | 1 ms | 256 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |