CoolFace
Datasetpublic

hackercupai/hackercup

Data Preview The data available in this preview contains a 10 row dataset: Sample Dataset ("sample"): This is a subset of the full dataset, containing data from 2023. To view full dataset, download output_dataset.parquet. This contains data from 2011 to 2023. Fields The dataset include the following fields: name (string) year (string) round (string) statement (string) input (string) solution (string) code (string) sample_input (string) sample_output (string)… See the full description on the dataset page: https://huggingface.co/datasets/hackercupai/hackercup.

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
24likes2.2kdownloads
khajiit.cpp146 linesDownload Raw Back to finals
1// Khajiit
2// Solution by Jacob Plachta
3
4#define DEBUG 0
5
6#include <algorithm>
7#include <functional>
8#include <numeric>
9#include <iostream>
10#include <iomanip>
11#include <cstdio>
12#include <cmath>
13#include <complex>
14#include <cstdlib>
15#include <ctime>
16#include <cstring>
17#include <cassert>
18#include <string>
19#include <vector>
20#include <list>
21#include <map>
22#include <set>
23#include <unordered_map>
24#include <unordered_set>
25#include <deque>
26#include <queue>
27#include <stack>
28#include <bitset>
29#include <sstream>
30using namespace std;
31
32#define LL long long
33#define LD long double
34#define PR pair<int,int>
35
36#define Fox(i,n) for (i=0; i<n; i++)
37#define Fox1(i,n) for (i=1; i<=n; i++)
38#define FoxI(i,a,b) for (i=a; i<=b; i++)
39#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
40#define FoxR1(i,n) for (i=n; i>0; i--)
41#define FoxRI(i,a,b) for (i=b; i>=a; i--)
42#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
43#define Min(a,b) a=min(a,b)
44#define Max(a,b) a=max(a,b)
45#define Sz(s) int((s).size())
46#define All(s) (s).begin(),(s).end()
47#define Fill(s,v) memset(s,v,sizeof(s))
48#define pb push_back
49#define mp make_pair
50#define x first
51#define y second
52
53template<typename T> T Abs(T x) { return(x < 0 ? -x : x); }
54template<typename T> T Sqr(T x) { return(x * x); }
55string plural(string s) { return(Sz(s) && s[Sz(s) - 1] == 'x' ? s + "en" : s + "s"); }
56
57const int INF = (int)1e9;
58const LD EPS = 1e-12;
59const LD PI = acos(-1.0);
60
61#if DEBUG
62#define GETCHAR getchar
63#else
64#define GETCHAR getchar_unlocked
65#endif
66
67bool Read(int& x) {
68	char c, r = 0, n = 0;
69	x = 0;
70	for (;;) {
71		c = GETCHAR();
72		if ((c < 0) && (!r))
73			return(0);
74		if ((c == '-') && (!r))
75			n = 1;
76		else if ((c >= '0') && (c <= '9'))
77			x = x * 10 + c - '0', r = 1;
78		else if (r)
79			break;
80	}
81	if (n)
82		x = -x;
83	return(1);
84}
85
86bool ReadLL(LL& x) {
87	char c, r = 0, n = 0;
88	x = 0;
89	for (;;) {
90		c = GETCHAR();
91		if ((c < 0) && (!r))
92			return(0);
93		if ((c == '-') && (!r))
94			n = 1;
95		else if ((c >= '0') && (c <= '9'))
96			x = x * 10 + c - '0', r = 1;
97		else if (r)
98			break;
99	}
100	if (n)
101		x = -x;
102	return(1);
103}
104
105#define MOD 1000000007
106#define LIM 1000005
107
108int N, M;
109char X[LIM], Y[LIM];
110
111LL Solve(int s) {
112	int i;
113	LL sum = 0;
114	int hasA = 0, needsA = 0;
115	FoxR(i, M) {
116		if (X[s + i] == 'A')
117			hasA++;
118		if (Y[s + i] == 'A')
119			needsA++;
120		sum += Abs(hasA - needsA);
121	}
122	return(sum);
123}
124
125int main() {
126	if (DEBUG)
127		freopen("in.txt", "r", stdin);
128	// vars
129	int T, t;
130	int i;
131	// testcase loop
132	Read(T);
133	Fox1(t, T) {
134		// input
135		Read(N), Read(M);
136		scanf("%s%s", &X, &Y);
137		// handle each spoke
138		LL ans = 0;
139		Fox(i, N)
140			ans += Solve(i * M + 1);
141		// output
142		printf("Case #%d: %lld\n", t, ans);
143	}
144	return(0);
145}
146