Submission #1529270
Source Code Expand
#include <bits/stdc++.h>
#define debug(x) //cout << #x << " = " << x << endl;
#define rep(i, a, b) for(int i=a; i<b; i++)
using namespace std;
typedef long long ll;
ll start(const string a, const string b){
if( a[0] == b[0] )
return 3LL;
else
return 6LL;
}
ll transition(const string a, const string b, int i){
if( a[i] == b[i] ){
if( a[i+1] == b[i+1] ) return 2LL;
else return 2LL;
}else{
if( a[i+1] == b[i+1] ) return 1LL;
else return 3LL;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
//const ll mod = 1000000007;
const ll mod = 1e9+7;
int n;
cin >> n;
string s1, s2;
cin >> s1 >> s2;
ll ans = start(s1, s2);
debug(ans);
int i = 0;
if( ans == 6 )
i++;
while( i < s1.size()-1 ){
ll tr = transition(s1, s2, i);
ans = (ans*tr)%mod;
debug(ans);
if( s1[i+1] == s2[i+1] )
i++;
else
i += 2;
if( i == s1.size()-1) break;
}
cout << ans << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Coloring Dominoes |
| User | blackarrow |
| Language | C++14 (GCC 5.4.1) |
| Score | 400 |
| Code Size | 1063 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 256 KiB |
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 KiB |
| 10.txt | AC | 1 ms | 256 KiB |
| 11.txt | AC | 1 ms | 256 KiB |
| 12.txt | AC | 1 ms | 256 KiB |
| 13.txt | AC | 1 ms | 256 KiB |
| 14.txt | AC | 1 ms | 256 KiB |
| 15.txt | AC | 1 ms | 256 KiB |
| 16.txt | AC | 1 ms | 256 KiB |
| 17.txt | AC | 1 ms | 256 KiB |
| 18.txt | AC | 1 ms | 256 KiB |
| 19.txt | AC | 1 ms | 256 KiB |
| 2.txt | AC | 1 ms | 256 KiB |
| 20.txt | AC | 1 ms | 256 KiB |
| 21.txt | AC | 1 ms | 256 KiB |
| 22.txt | AC | 1 ms | 256 KiB |
| 3.txt | AC | 1 ms | 256 KiB |
| 4.txt | AC | 1 ms | 256 KiB |
| 5.txt | AC | 1 ms | 256 KiB |
| 6.txt | AC | 1 ms | 256 KiB |
| 7.txt | AC | 1 ms | 256 KiB |
| 8.txt | AC | 1 ms | 256 KiB |
| 9.txt | AC | 1 ms | 256 KiB |
| sample1.txt | AC | 1 ms | 256 KiB |
| sample2.txt | AC | 1 ms | 256 KiB |
| sample3.txt | AC | 1 ms | 256 KiB |