提出 #46431032
ソースコード 拡げる
/*
Author : Hocky Yudhiono
Sel 10 Okt 2023 05:18:05
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<ll, ll> PLL;
typedef pair<ll, ll> pll;
typedef long double ld;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define pb push_back
#define fi first
#define se second
const double EPS = 1e-9;
const int INFMEM = 63;
// Do dir^1 to get reverse direction
const int dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const int dy[8] = {1, -1, 0, 0, 1, -1, -1, 1};
const char dch[4] = {'R', 'L', 'D', 'U'};
// Do (dir + 2)%4 to get reverse direction
// const int dx[8] = {-1,0,1,0,-1,1,1,-1};
// const int dy[8] = {0,1,0,-1,1,1,-1,-1};
// const char dch[4] = {'U','R','D','L'};
const double PI = 3.141592653589793;
inline void fasterios() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
}
#define endl '\n'
const int MOD = 1000000007;
// const int MOD = 998244353;
int main() {
fasterios();
int n, m; cin >> n >> m;
string s, t; cin >> s >> t;
int can = 3;
for (int i = 0; i < n; i++) {
if (s[i] != t[i]) {
can ^= 1;
break;
}
}
for (int i = n - 1, j = m - 1; i >= 0; i--, j--) {
if (s[i] != t[j]) {
can ^= 2;
break;
}
}
if(can == 0 || can == 3) can ^= 3;
cout << can << endl;
}
提出情報
提出日時 |
|
問題 |
B - Prefix and Suffix |
ユーザ |
hocky |
言語 |
C++ 20 (gcc 12.2) |
得点 |
200 |
コード長 |
1691 Byte |
結果 |
AC |
実行時間 |
1 ms |
メモリ |
3632 KiB |
ジャッジ結果
セット名 |
Sample |
All |
得点 / 配点 |
0 / 0 |
200 / 200 |
結果 |
|
|
セット名 |
テストケース |
Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 03_hack_00.txt, 03_hack_01.txt, 03_hack_02.txt, 03_hack_03.txt |
ケース名 |
結果 |
実行時間 |
メモリ |
00_sample_00.txt |
AC |
1 ms |
3428 KiB |
00_sample_01.txt |
AC |
1 ms |
3508 KiB |
00_sample_02.txt |
AC |
1 ms |
3500 KiB |
00_sample_03.txt |
AC |
1 ms |
3512 KiB |
01_random_00.txt |
AC |
1 ms |
3588 KiB |
01_random_01.txt |
AC |
1 ms |
3496 KiB |
01_random_02.txt |
AC |
1 ms |
3576 KiB |
01_random_03.txt |
AC |
1 ms |
3488 KiB |
01_random_04.txt |
AC |
1 ms |
3580 KiB |
01_random_05.txt |
AC |
1 ms |
3632 KiB |
01_random_06.txt |
AC |
1 ms |
3432 KiB |
01_random_07.txt |
AC |
1 ms |
3508 KiB |
01_random_08.txt |
AC |
1 ms |
3492 KiB |
01_random_09.txt |
AC |
1 ms |
3488 KiB |
01_random_10.txt |
AC |
1 ms |
3580 KiB |
01_random_11.txt |
AC |
1 ms |
3492 KiB |
02_corner_00.txt |
AC |
1 ms |
3632 KiB |
02_corner_01.txt |
AC |
1 ms |
3436 KiB |
02_corner_02.txt |
AC |
1 ms |
3580 KiB |
02_corner_03.txt |
AC |
1 ms |
3432 KiB |
03_hack_00.txt |
AC |
1 ms |
3508 KiB |
03_hack_01.txt |
AC |
1 ms |
3436 KiB |
03_hack_02.txt |
AC |
1 ms |
3496 KiB |
03_hack_03.txt |
AC |
1 ms |
3384 KiB |