Submission #1039520

# Submission time Handle Problem Language Result Execution time Memory
1039520 2024-07-31T02:42:27 Z DucNguyen2007 Mergers (JOI19_mergers) C++14
0 / 100
25 ms 17864 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=5e5+5;
const ll inf=2e18;
int n,k,c[maxN+1];
vector<int> adj[maxN+1];
set<int> se;
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
    {
        cin>>c[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(adj[i].size()==1)
        {
            se.insert(c[i]);
        }
    }
    cout<<se.size()/2;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Incorrect 2 ms 12892 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Incorrect 2 ms 12892 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Incorrect 2 ms 12892 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 17864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Incorrect 2 ms 12892 KB Output isn't correct
3 Halted 0 ms 0 KB -