답안 #947920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947920 2024-03-17T09:14:59 Z Darren0724 Newspapers (CEOI21_newspapers) C++17
4 / 100
6 ms 11356 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
vector<int> adj[N],vis(N),a[N];

void dfs(int k,int pa,int deep){
    vis[k]=1;
    a[k].push_back(deep);
    for(int j:adj[k]){
        if(j==pa)continue;
        dfs(j,k,deep+1);
        a[k].push_back(a[j][0]);
    }
    sort(all(a[k]),greater<int>());
}
int32_t main() {
    LCBorz;
    int n,m;cin>>n>>m;
    if(m>=n){
        cout<<"NO"<<endl;
        return 0;
    }
    if(n==1){
        cout<<"YES\n1\n1\n";
        return 0;
    }
    if(n==2){
        cout<<"YES\n2\n1 1\n";
        return 0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[i].clear();
        }
        dfs(i,i,0);
        if(a[i].size()<3){
            continue;
        }
        if(a[i][2]>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES\n1\n1";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 4 ms 11296 KB Output is correct
3 Partially correct 4 ms 11356 KB Failed to provide a successful strategy.
4 Partially correct 5 ms 11352 KB Failed to provide a successful strategy.
5 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
6 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
7 Correct 5 ms 11352 KB Output is correct
8 Partially correct 4 ms 11356 KB Failed to provide a successful strategy.
9 Incorrect 5 ms 11356 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 4 ms 11356 KB Output is correct
3 Partially correct 4 ms 11356 KB Failed to provide a successful strategy.
4 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
5 Partially correct 5 ms 11332 KB Failed to provide a successful strategy.
6 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
7 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
8 Partially correct 4 ms 11356 KB Failed to provide a successful strategy.
9 Partially correct 5 ms 11352 KB Failed to provide a successful strategy.
10 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
11 Partially correct 6 ms 11356 KB Failed to provide a successful strategy.
12 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
13 Partially correct 5 ms 11352 KB Failed to provide a successful strategy.
14 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
15 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
16 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
17 Partially correct 6 ms 11352 KB Failed to provide a successful strategy.
18 Partially correct 5 ms 11352 KB Failed to provide a successful strategy.
19 Partially correct 6 ms 11352 KB Failed to provide a successful strategy.
20 Partially correct 6 ms 11356 KB Failed to provide a successful strategy.
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 4 ms 11296 KB Output is correct
3 Partially correct 4 ms 11356 KB Failed to provide a successful strategy.
4 Partially correct 5 ms 11352 KB Failed to provide a successful strategy.
5 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
6 Partially correct 5 ms 11356 KB Failed to provide a successful strategy.
7 Correct 5 ms 11352 KB Output is correct
8 Partially correct 4 ms 11356 KB Failed to provide a successful strategy.
9 Incorrect 5 ms 11356 KB Output isn't correct
10 Halted 0 ms 0 KB -