Submission #1996172
Source Code Expand
#include <algorithm> #include <cmath> #include <iostream> #include <iomanip> #include <map> #include <string> #include <vector> #include <queue> #include <stack> #include <set> #include <list> #include <cstdio> #define INF 1000000000000 #define MOD 1000000007ll #define EPS 1e-10 #define REP(i,m) for(long long i=0; i<m; i++) #define FOR(i,n,m) for(long long i=n; i<m; i++) #define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; } #define ALL(v) v.begin(),v.end() #define pb push_back using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef long double ld; using namespace std; int main(){ int n; string s1, s2; cin >> n >> s1 >> s2; ll ans = 1; stack<int> st; REP(i, n){ if(s1[i] == s2[i]) st.push(1); else{ st.push(2); i++; } } int x = st.top(); st.pop(); if(x == 1) ans = 3; else ans = 6; while(st.size()){ int y = st.top(); st.pop(); if(x == 1) ans = (ans * 2) % MOD; if(x == 2 && y == 2) ans = (ans * 3) % MOD; x = y; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Coloring Dominoes |
User | EctoPlasma |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1152 Byte |
Status | AC |
Exec Time | 2 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 | 2 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 |