Submission #4635613
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3")
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x)
#endif
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- __MAKE_TIME__ Problem: __PROBLEM__ / Link: __CONTEST_URL__ ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
LL N; cin >> N;
string s, t; cin >> s >> t;
LL ans = 1;
LL prev = 3;
FOR(i, 0, N) {
if (s[i] == t[i]) {// |
if (i) {
ans *= 2 - prev;
}
else {
ans *= 3;
}
prev = 0;
}
else { // ==
if (i) {
ans *= 2 + prev;
}
else {
ans *= 6;
}
prev = 1;
i++;
}
ans %= MOD;
}
cout << ans << endl;
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Coloring Dominoes |
| User |
Yang33 |
| Language |
C++14 (GCC 5.4.1) |
| Score |
400 |
| Code Size |
1630 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 |