https://ac.nowcoder.com/acm/contest/318#question

题解:真正的签到题。
由于通过一个题目只会给一个气球,所以我们可以开一个二维数组vis[i][j]来记录一下,第i 个队是否通过了第j 个题目,vis[i][j] = 1表示已经通过,vis[i][j] = 0,则表示没有。接着再用一个数组num统计一下每个队伍通过的题目数量即可。由于是多组输入,不要忘记初始化。

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=10000;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
int a[N];
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    scanf("%d",&t);
    int T=0;
    while(t--){
        scanf("%d%d",&n,&m);
        char c,str[5];
        map<char,int>s[N];
        memset(a,0,sizeof(a));
        for(int i=1;i<=m;i++){
            scanf("%d %c %s",&q,&c,str);
            if(!s[q][c]&&str[0]=='A'){
                a[q]++;
                s[q][c]++;
            }
        }
        printf("Case #%d:\n",++T);
        for(int i=1;i<=n;i++){
            if(i!=n)
                printf("%d ",a[i]);
            else
                printf("%d\n",a[i]);
        }
    }
    //cout << "Hello world!" << endl;
    return 0;
}

C++版本二

#include <bits/stdc++.h>
using namespace std;

int n, m, _;
int num[55];
bool vis[55][15];

int main() {
	int cas = 1;
	for (scanf("%d", &_); _; _--) {
		memset(num, 0, sizeof(num));
		memset(vis, 0, sizeof(vis));
		scanf("%d%d", &n, &m);
		int team_id;
		char problem_id[2], submit_status[5];
		while (m--) {
			scanf("%d%s%s", &team_id, problem_id, submit_status);
			if (strcmp(submit_status, "AC") == 0) {
				if (!vis[team_id][problem_id[0] - 'A']) {
					num[team_id]++;
					vis[team_id][problem_id[0] - 'A'] = 1;
				}
			}
		}
		printf("Case #%d:\n", cas++);
		for (int i = 1; i <= n; i++)
			printf("%d%c", num[i], i == n ? '\n' : ' ');
	}
	return 0;
}