题目连接
模拟就好
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
void solve()
{
long long a[2] = {0};
long long c = 0;
char s1[19];
char s2[19];
gets(s1);
a[c]++;
for(;;) {
gets(s2);
if (!strcmp(s2, "END")) break;
if (!strcmp(s1, s2)) {
c = !c;
a[c]++;
}
else{
a[c]++;
}
strcpy(s1, s2);
}
long long ans = a[0] * a[1];
printf("%lld\n", ans);
}
int main()
{
// freopen("input.txt", "r", stdin);
int t;
scanf("%d\n", &t);
for (int i = 0; i < t; i++) {
solve();
}
}