Submission #21122079


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
#include <atcoder/convolution>
using namespace atcoder;
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














string S, T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S >> T;
	reverse(all(T));

	int NS = S.length();
	int NT = T.length();

	vector<ll> a01(NS);
	rep(i, 0, NS) a01[i] = (S[i] == '0' ? 1 : 0);

	vector<ll> b01(NT);
	rep(i, 0, NT) b01[i] = (T[i] == '0' ? 0 : 1);

	auto c01 = convolution(b01, a01);

	vector<ll> a10(NS);
	rep(i, 0, NS) a10[i] = (S[i] == '0' ? 0 : 1);

	vector<ll> b10(NT);
	rep(i, 0, NT) b10[i] = (T[i] == '0' ? 1 : 0);

	auto c10 = convolution(b10, a10);

	ll ans = inf;
	rep(i, NT - 1, NS) chmin(ans, c01[i] + c10[i]);
	cout << ans << endl;

}





Submission Info

Submission Time
Task F - Substring 2
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 600
Code Size 2023 Byte
Status AC
Exec Time 413 ms
Memory 91816 KiB

Judge Result

Set Name Sample All after_contest
Score / Max Score 0 / 0 600 / 600 0 / 0
Status
AC × 3
AC × 35
AC × 3
Set Name Test Cases
Sample 01_sample.txt, 02_sample.txt, 03_sample.txt
All 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_hand.txt, 05_hand.txt, 06_small.txt, 07_small.txt, 08_small.txt, 09_small.txt, 10_small.txt, 11_small.txt, 12_small.txt, 13_small.txt, 14_small.txt, 15_small.txt, 16_small.txt, 17_small.txt, 18_small.txt, 19_small.txt, 20_large.txt, 21_large.txt, 22_large.txt, 23_large.txt, 24_large.txt, 25_large.txt, 26_large.txt, 27_large.txt, 28_max.txt, 29_max.txt, 30_max.txt, 31_max.txt, 32_max.txt, 33_max.txt, 34_max.txt, 35_max.txt
after_contest 36_after_contest.txt, 37_after_contest.txt, 38_after_contest.txt
Case Name Status Exec Time Memory
01_sample.txt AC 10 ms 3584 KiB
02_sample.txt AC 3 ms 3584 KiB
03_sample.txt AC 2 ms 3520 KiB
04_hand.txt AC 2 ms 3508 KiB
05_hand.txt AC 3 ms 3512 KiB
06_small.txt AC 3 ms 3516 KiB
07_small.txt AC 2 ms 3612 KiB
08_small.txt AC 2 ms 3616 KiB
09_small.txt AC 6 ms 3524 KiB
10_small.txt AC 1 ms 3596 KiB
11_small.txt AC 5 ms 3612 KiB
12_small.txt AC 3 ms 3608 KiB
13_small.txt AC 3 ms 3516 KiB
14_small.txt AC 2 ms 3548 KiB
15_small.txt AC 2 ms 3608 KiB
16_small.txt AC 2 ms 3456 KiB
17_small.txt AC 2 ms 3516 KiB
18_small.txt AC 3 ms 3596 KiB
19_small.txt AC 2 ms 3524 KiB
20_large.txt AC 194 ms 31388 KiB
21_large.txt AC 195 ms 40048 KiB
22_large.txt AC 199 ms 44364 KiB
23_large.txt AC 201 ms 45576 KiB
24_large.txt AC 382 ms 62172 KiB
25_large.txt AC 394 ms 74216 KiB
26_large.txt AC 205 ms 48444 KiB
27_large.txt AC 389 ms 66632 KiB
28_max.txt AC 52 ms 43264 KiB
29_max.txt AC 55 ms 43192 KiB
30_max.txt AC 394 ms 74260 KiB
31_max.txt AC 392 ms 74356 KiB
32_max.txt AC 413 ms 91816 KiB
33_max.txt AC 410 ms 91788 KiB
34_max.txt AC 412 ms 91748 KiB
35_max.txt AC 411 ms 91784 KiB
36_after_contest.txt AC 385 ms 64952 KiB
37_after_contest.txt AC 394 ms 74256 KiB
38_after_contest.txt AC 403 ms 82840 KiB