QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#463819#2524. Dessert Caféyzkkai#WA 0ms3532kbC++20869b2024-07-05 14:50:232024-07-05 14:50:23

Judging History

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

  • [2024-07-05 14:50:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-07-05 14:50:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
inline void solve() {
    int n, k;
    cin >> n >> k;
    vector<vector<pii>> v(n+1);
    set<int> st;
    for(int i = 0;i < n - 1;i ++){
        int x,y,z;
        cin >> x >> y >> z;
        v[x].emplace_back(z, y);
        v[y].emplace_back(z, x);
    }
    
    for(int i = 0;i < k;i ++){
        int cur;
        cin >> cur;
        sort(v[cur].begin(), v[cur].end());
        if(v[cur].size() > 1){
            if(v[cur][0].first != v[cur][1].first)
                st.emplace(v[cur][0].second);
        }else{
                st.emplace(v[cur][0].second);
        }
        st.emplace(cur);
    }
    cout << st.size() << "\n";

}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;

    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

9 2
1 2 8
2 4 7
4 3 6
4 6 4
5 6 3
6 7 2
6 9 5
9 8 6
1 8

output:

4

result:

wrong answer 1st lines differ - expected: '6', found: '4'