Submission #63831114


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, k;
cin>>n>>k;
int nk = n*k;
if(nk==1){
cout<<"Yes"<<"\n";
return 0;
}
vector<vector<int>> adj(nk);
for(int i=0;i<nk-1;i++){
int u,v;
cin>>u>>v;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>

using namespace std;

int main(){

    int n, k; 
    cin>>n>>k;

    int nk = n*k;

    if(nk==1){
        cout<<"Yes"<<"\n";
        return 0;
    }

    vector<vector<int>> adj(nk);

    for(int i=0;i<nk-1;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }

    queue<int> q;
    vector<bool> vis(nk,false); 

    for(int i=0;i<nk;i++){
        if(adj[i].size()==1) {
            q.push(i);
        }
    }
    
    bool flag = true;

    while(!q.empty()){
        int u = q.front();
        q.pop();
        if(vis[u]) continue;
        vis[u] = true;
        int ck = k-1;
        while(ck--){
            bool nn = false;
            for(auto e:adj[u]) if(!vis[e]){
                nn = true;
                u = e;
                vis[u] = true;
                break;
            }
            if(!nn) break;
        }

        if(ck!=-1){
            flag = false;
            break;
        }else{
            for(auto e:adj[u]) if(!vis[e]){
                q.push(e);
            }
        }
    }
    
    for(auto e:vis) if(!e){
        flag = false;
        break;
    }

    cout<<(flag?"Yes":"No")<<"\n";


    return 0;
}


Submission Info

Submission Time
Task E - Path Decomposition of a Tree
User stark0509
Language C++ 17 (gcc 12.2)
Score 0
Code Size 1321 Byte
Status WA
Exec Time 113 ms
Memory 15776 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 475
Status
AC × 2
AC × 38
WA × 13
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3484 KB
00_sample_02.txt AC 1 ms 3500 KB
01_random_01.txt AC 99 ms 14676 KB
01_random_02.txt AC 101 ms 14688 KB
01_random_03.txt AC 105 ms 14784 KB
01_random_04.txt AC 102 ms 14824 KB
01_random_05.txt AC 100 ms 14920 KB
01_random_06.txt AC 100 ms 14820 KB
01_random_07.txt AC 102 ms 14832 KB
01_random_08.txt AC 101 ms 14680 KB
01_random_09.txt AC 107 ms 14680 KB
01_random_10.txt AC 104 ms 14784 KB
01_random_11.txt AC 104 ms 14772 KB
01_random_12.txt AC 104 ms 14692 KB
01_random_13.txt AC 102 ms 14764 KB
01_random_14.txt AC 99 ms 14788 KB
01_random_15.txt AC 104 ms 14700 KB
01_random_16.txt WA 99 ms 14220 KB
01_random_17.txt WA 99 ms 14184 KB
01_random_18.txt WA 97 ms 14304 KB
01_random_19.txt WA 98 ms 14200 KB
01_random_20.txt AC 104 ms 14252 KB
01_random_21.txt AC 99 ms 14172 KB
01_random_22.txt AC 97 ms 14232 KB
01_random_23.txt AC 99 ms 14232 KB
01_random_24.txt AC 103 ms 14172 KB
01_random_25.txt AC 99 ms 14032 KB
01_random_26.txt WA 102 ms 14220 KB
01_random_27.txt WA 97 ms 14228 KB
01_random_28.txt WA 97 ms 14260 KB
01_random_29.txt WA 98 ms 14180 KB
01_random_30.txt AC 100 ms 14224 KB
01_random_31.txt AC 99 ms 14312 KB
01_random_32.txt AC 98 ms 14252 KB
01_random_33.txt AC 107 ms 14260 KB
01_random_34.txt WA 102 ms 14180 KB
01_random_35.txt AC 105 ms 14220 KB
01_random_36.txt WA 99 ms 14224 KB
01_random_37.txt WA 99 ms 14392 KB
01_random_38.txt WA 96 ms 14168 KB
01_random_39.txt WA 102 ms 14224 KB
01_random_40.txt AC 104 ms 14224 KB
01_random_41.txt AC 103 ms 14292 KB
01_random_42.txt AC 101 ms 14232 KB
01_random_43.txt AC 112 ms 14156 KB
01_random_44.txt AC 107 ms 14168 KB
01_random_45.txt AC 99 ms 14152 KB
02_handmade_01.txt AC 1 ms 3492 KB
02_handmade_02.txt AC 113 ms 14152 KB
02_handmade_03.txt AC 104 ms 14152 KB
02_handmade_04.txt AC 76 ms 15776 KB


2025-04-01 (Tue)
20:25:07 +00:00