ZOJ

来源:互联网 发布:文字图片制作软件 编辑:程序博客网 时间:2024/06/06 00:02
//其实也算水题,关键是要耐心做,不要浮躁#include <cstdio>#include <iostream>#include <string>#include <cstring>using namespace std;const int maxn = 205;string name[maxn];int ans[maxn];int rec[maxn][maxn]; //record[i][j] 为第i个人的第j个回答 int main(){int t;cin >> t;while (t--){memset(rec, 0, sizeof(rec));int n, q, c, d;cin >> n >> q >> c;for (int i = 0; i < c; i++) cin >> name[i];for (int i = 0; i < q; i++) //枚举题目 {int num; string x;cin >> num;while (num--){cin >> x;for (int j = 0; j < c; j++) //枚举人 {if (name[j] == x){rec[j][i] = 1;}}}}for (int i = 0; i < n; i++) // 枚举要找的朋友数 {int fj; // fianl jfor (int j = 0; j < q; j++) cin >> ans[j]; // 将当前要找的人,的所有答案输入 int cnt = 0; // countint m;for (int k = 0; k < c; k++) // 枚举人 {bool flag = true; for (m = 0; m < q; m++) //枚举q道题的答案 if (ans[m] != rec[k][m]){flag = false;break;}if (flag){cnt++;fj = k;}}if (cnt == 1) cout << name[fj] << endl;else cout << "Let's go to the library!!" << endl;}}return 0;}

原创粉丝点击