QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#252905#6396. Puzzle: KusabisupepapupuCompile Error//C++172.2kb2023-11-16 14:41:202023-11-16 14:41:20

Judging History

你现在查看的是最新测评结果

  • [2023-11-16 14:41:20]
  • 评测
  • [2023-11-16 14:41:20]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
#define debug(x) cout << #x << ": " << x << el
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;

void inc(ll &a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

void dec(ll &a, ll b) {
    a -= b;
    if (a < 0) a += mod;
}

ll add(ll a, ll b) {
    a += b;
    return a >= mod ? a - mod : a;
}

ll del(ll a, ll b) {
    a -= b;
    return a < 0 ? a + mod : a;
}

vector<int> G[N];
vector<pii> chang, duan, tong;
int dep[N];

void dfs(int u, int fa) {
    dep[u] = dep[fa] + 1;
    for (int v: G[u]) 
        if (v != fa) dfs(v, u);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for (int i = 1; i < n; ++i) {
        int a, b; string str; cin >> a >> b >> str;
        if (str == "Chang") chang.emplace_back(a, b);
        else if (str == "Duan") duan.emplace_back(a, b);
        else if (str == "Tong") tong.emplace_back(a, b);
        G[a].emplace_back(b), G[b].emplace_back(a);
        cout << 
    }
    dfs(1, 0);
    set<pii> sc, sd, st;
    for (auto[a, b]: chang) {
        if (dep[a] < dep[b]) swap(a, b);
        sc.insert({dep[a], a});
    }
    for (auto[a, b]: duan) {
        if (dep[a] < dep[b]) swap(a, b);
        sd.insert({dep[a], a});
    }
    for (auto[a, b]: tong) {
        if (dep[a] < dep[b]) swap(a, b);
        st.insert({dep[a], a});
    }
    vector<pii> ans;
    if (st.size() & 1) return cout << "NO\n", 0;
    while (st.size()) {
        if (st.begin()->x != (++st.begin())->x) return cout << "NO\n", 0;
        ans.emplace_back(st.begin()->y, (++st.begin())->y);
        st.erase(st.begin()), st.erase(st.begin());
    }
    if (sc.size() != sd.size()) return cout << "NO\n", 0;
    while (sd.size()) {
        auto[d, u] = *sd.begin();
        sd.erase(sd.begin());
        auto it = sc.lower_bound({d + 1, 0});
        if (it == sc.end()) return cout << "NO\n", 0;
        ans.emplace_back(u, it->y);
        sc.erase(it);
    }
    cout << "YES\n";
    for (auto[a, b]: ans) cout << a << ' ' << b << el;
}

Details

answer.code: In function ‘int main()’:
answer.code:53:5: error: expected primary-expression before ‘}’ token
   53 |     }
      |     ^