제출 #1328504

#제출 시각아이디문제언어결과실행 시간메모리
1328504michael12Labels (NOI20_labels)C++20
0 / 100
595 ms1114112 KiB
#include<bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int inf = 1e9;
struct DSU{
    int n;
    vector<int> p;
    DSU(int size){
        n = size;
        p.resize(n);
        for(int i = 0; i < n; i++){
            p[i] = i;
        }
    }
    int find(int u){
        if(u == p[u]) return u;
        return p[u] = p[find(u)];
    }
    void unite(int u, int v){
        int a = find(u);
        int b = find(v);
        if(a != b){
            p[a] = b;
        }
    }
};

signed main(){
    int n;
    cin >> n;
    
    vector<int> d(n - 1);
    int a[n][n];
    memset(a, 0, sizeof(a));
    for(int i = 0; i < n; i++){
        cin >> d[i];
        a[i][0] = i + 1;
    }
    int cur = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j < n; j++){
            a[i][j] = a[i][j - 1] + d[j - 1];
        }
    }
    vector<int> adj[n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[i][j] >= 1 && a[i][j] <= n){
                adj[i].push_back(a[i][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(adj[i].size() == n){
            ans += 1;
        }
    }
    if(ans >= 2){
        cout << "-1";
    }
    else{
        for(int i = 0; i < n - 1; i++){
            if(adj[i].size() == n){
                for(auto v : adj[i]){
                    cout << v << " ";
                }
            }
            return 0;
        }
    }
    
    
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...