社区讨论
求助昨日比赛第一题 P9680 string[_view]
学术版参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lo181zts
- 此快照首次捕获于
- 2023/10/22 16:43 2 年前
- 此快照最后确认于
- 2023/11/02 16:33 2 年前
CPP
#include <bits/stdc++.h>
using namespace std;
struct liu {
std::string a;
int b;
} c[100000];
int main() {
int sum = 0;
int n, num = 0;
std::cin >> n;
for (int i = 1; i <= n; i++) {
std::string line, lion;
bool flag = false;
int aa = 0;
std::cin >> line >> lion;
int open = lion.find_first_of('(');
int close = lion.find_last_of(')');
std::string a, b;
a = lion.substr(0, open);
if (lion[open + 1] == '"')
b = lion.substr(open + 2, lion.size() - a.size() - 5);
else
b = lion.substr(open + 1, lion.size() - a.size() - 3);
for (int j = 1; j <= num; j++) {
if (c[j].a == b) {
flag = true;
aa = j;
break;
}
}
if (flag)
c[++num].a = a, c[num].b = c[aa].b;
else
c[++num].a = a, c[num].b = b.size();
if (line == "string")
sum += c[num].b;
}
std::cout << sum << std::endl;
return 0;
}//全部RE
回复
共 0 条回复,欢迎继续交流。
正在加载回复...