社区讨论
0pts · 奇怪错误
P2814家谱参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lo31k8aw
- 此快照首次捕获于
- 2023/10/23 23:17 2 年前
- 此快照最后确认于
- 2023/10/23 23:17 2 年前
CPP
#include <bits/stdc++.h>
#define fo(i,a,b) for (auto i = a; i < b; i ++)
#define foe(i,a,b) for (auto i = a; i <= b; i ++)
#define of(i,b,a) for (auto i = b; i > a; i --)
#define ofe(i,b,a) for (auto i = b; i >= a; i --)
#define fi(i,s) for (auto i : s)
#define print(fmt, ...) printf(fmt, __VA_ARGS__), printf("\n")
#define sq(x) ((x) * (x))
#define cb(x) (sq(x) * (x))
#define ks(s) (string(s))
#define ts(s) (to_string(s))
#define mem(s, a) memset(s, a, sizeof(s))
#define v1 first
#define v2 second
using namespace std;
typedef long long ll;
typedef unsigned ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
const ll inf_ll = 0x3f3f3f3f3f3f3f3fll;
template<class _Tp, const size_t __len>
using arr = _Tp [__len];
template<class _Tp, const size_t __len, const size_t __len2>
using arr2 = _Tp [__len][__len2];
template<class _Tp>
inline _Tp read() {
char c = getchar();
_Tp x = 0;
int f = 1;
for(; !isdigit(c); c = getchar())
if (c == '-') f *= -1;
for(; isdigit(c); c = getchar()) x = x * 10 + (c - 48);
return x * f;
}
/* ====================== */
map<string, string> a;
string find_acst(string s) { // 找到祖先
return a[s] == s ? a[s] : (a[s] = find_acst(a[s]));
}
int main() {
char c;
string s, t;
while ((c = getchar()) != '$') {
getline(cin, s);
switch (c) {
case '#':
t = s;
if (a.find(s) == a.end()) a[s] = t;
continue;
case '+':
a[s] = t;
continue;
case '?':
cout << s << ' ' << find_acst(s) << endl;
continue;
}
}
}
然后结果 0 pts:
555到底哪里错了?提交了5遍都是这样,下载样例一看输出一模一样,本机&洛谷ide都是一样的
回复
共 3 条回复,欢迎继续交流。
正在加载回复...