代码实现如下
#include<iostream>
using namespace std;
int main() {
int A, B, n, ha = 0, hb = 0, pa, pb, pah, pbh;
cin >> A >> B >> n;
while (n--) {
int flaga = 0, flagb = 0;
cin >> pa >> pah >> pb >> pbh;
if (pa + pb == pah)
flaga = 1;
if (pa + pb == pbh)
flagb = 1;
if (flaga == 1 && flagb == 0) {
ha += 1;
}else if (flaga == 0 && flagb == 1) {
hb += 1;
}
if (ha > A) {
cout << "A" << endl << hb << endl;
return 0;
}
else if (hb > B) {
cout << "B" << endl << ha << endl;
return 0;
}
}
return 0;
}