【二月份 -- 基础语法组】-- T2 --四元组

· · 个人记录

https://cspjs.online/contest/649/problem/2

#include <bits/stdc++.h>
using namespace std;
const int SIZE = 10;
int n;
char str[SIZE], ans[SIZE];
int main() {
    freopen("choosen.in", "r", stdin);
    freopen("choosen.out", "w", stdout);
    int s = 0;
    cin >> n;
    while (n--) {
        scanf("%s", str + 1);
        scanf("%s", ans + 1);
        int len_str = (int)strlen(str + 1), len_ans = (int)strlen(ans + 1);
        if (len_str == 1 && len_ans == 1) {
            s += (str[1] == ans[1]) ? 3 : 0;
        } else {
            sort(str + 1, str + len_str + 1);
            sort(ans + 1, ans + len_ans + 1);
            int cnt = 0;
            for (int i = 1; i <= len_str; ++i) {
                for (int j = 1; j <= len_ans; ++j) {
                    if (str[i] == ans[j])
                        ++cnt;
                }
            }
            s += cnt == len_ans ? 5 : (cnt == len_str ? 2 : 0);
        }
    }
    cout << s;
    return 0;
}