#include <iostream> using namespace std; bool notFalseGold(int i, int *num, char op) { bool found = false; for (int j = 1; j <= num[0] * 2; j++) { if (num[j] == i) { found = true; break; } } if (found && op == '=' || !found && op != '=' ) return false; else return true; } int main() { int number[101][1001];//行表示编号,列表示数据 char op[101]; //对比的结果:< > =这三种 int n, k; cin >> n >> k; for (int i = 0; i < k; i++) { cin >> number[i][0];//0号存两边的砝码个数 for (int j = 1; j <= number[i][0] * 2; j++) { cin >> number[i][j]; } cin.get();//吸收回车符 cin >> op[i];//读取比较的结果 } int t, i, no; for (t = 0, i = 1; i <= n; i++) { int j; for (j = 0; j < k && notFalseGold(i, number[i], op[j]); j++) { ;//此处只是分号 } if (j < k) continue; t ++; //可能的假金币加1 if (t > 1) break;//如果存在多个假的,那就不符合条件 else no = i;//记下假金币的编号 } if (t == 1) { cout << no << endl; } else { cout << 0 << endl; } return 0; }