2
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void solveGroup() {
|
||||
int fakeValue[12] = {};
|
||||
bool tempList[12] = {false};
|
||||
// int realCount = 0;
|
||||
vector<pair<string, string> > lighterResults;
|
||||
for (int _ = 0; _ < 3; _++) {
|
||||
string s1, s2, comparison;
|
||||
cin >> s1 >> s2 >> comparison;
|
||||
memset(tempList, false, sizeof(tempList));
|
||||
if (comparison == "even") {
|
||||
// 八个都是真的
|
||||
for (const char c: s1 + s2) {
|
||||
tempList[c - 'A'] = true;
|
||||
fakeValue[c - 'A'] -= 120;
|
||||
}
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (!tempList[i]) { fakeValue[i]++; }
|
||||
}
|
||||
} else {
|
||||
// 剩下四个是真的
|
||||
for (const char c: s1 + s2) {
|
||||
tempList[c - 'A'] = true;
|
||||
fakeValue[c - 'A']++;
|
||||
}
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (!tempList[i]) { fakeValue[i] -= 120; }
|
||||
}
|
||||
// 不着急比
|
||||
if (comparison == "down") {
|
||||
lighterResults.emplace_back(s2, s1);
|
||||
} else {
|
||||
lighterResults.emplace_back(s1, s2);
|
||||
}
|
||||
}
|
||||
for (const int val: fakeValue) {
|
||||
clog << val << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int theFakeOne = -1, maxFakeVal = -120;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (fakeValue[i] > maxFakeVal) {
|
||||
maxFakeVal = fakeValue[i];
|
||||
theFakeOne = i;
|
||||
}
|
||||
}
|
||||
for (const auto &[s1, s2]: lighterResults) {
|
||||
for (const char c: s1) {
|
||||
if (c == 'A' + theFakeOne) {
|
||||
cout << static_cast<char>(theFakeOne + 'A') << " is the counterfeit coin and it is heavy." << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const char c: s2) {
|
||||
if (c == 'A' + theFakeOne) {
|
||||
cout << static_cast<char>(theFakeOne + 'A') << " is the counterfeit coin and it is light." << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int _ = 0; _ < n; _++) {
|
||||
solveGroup();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user