专栏文章
【二月份 -- 基础语法组】-- T2 --四元组
个人记录参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mipbdyvy
- 此快照首次捕获于
- 2025/12/03 09:14 3 个月前
- 此快照最后确认于
- 2025/12/03 09:14 3 个月前
https://cspjs.online/contest/649/problem/2
CPP#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;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...