0pts · 奇怪错误
  • 板块P2814 家谱
  • 楼主CarrotMeow
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/3/3 13:10
  • 上次更新2023/10/23 23:17:24
查看原帖
0pts · 奇怪错误
912750
CarrotMeow楼主2023/3/3 13:10
#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:

Wrong Answer.wrong answer On line 1 column 7, read (ASCII 13), expected .\color{White} \colorbox{Red}{Wrong Answer.wrong answer On line 1 column 7, read (ASCII 13), expected .}

555到底哪里错了?提交了5遍都是这样,下载样例一看输出一模一样,本机&洛谷ide都是一样的

2023/3/3 13:10
加载中...