Submission #300801

#TimeUsernameProblemLanguageResultExecution timeMemory
300801Nodir_BobievLabels (NOI20_labels)C++17
0 / 100
22 ms4396 KiB
/* +----------------------------------------------------------------+ | In the name of Allah, the most Gracious and the most Merciful. | +----------------------------------------------------------------+ Our hearts quake with fear of you Our hearts wake with love for you And to Islam we must be true In everything we think and do. -------------------------------- When your heart is breaking And your pain makes you fall Remember just remember Allah Sees it all. */ # include <bits/stdc++.h> # define FILE using namespace std; int main(){ # ifdef FILEs freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout ); # endif ios_base::sync_with_stdio(false); int n; cin >> n; int d[n] = {}; for( int i = 1; i < n; i ++ ){ cin >> d[i]; } long long cnt[n] = {}, eq = 0, mx = 0, mn = 0, id = -1, val = -1; for( int i = 1; i < n; i ++ ){ cnt[i] = d[i] + cnt[i-1]; if( cnt[i] - mn == n-1 ){ id = i; val = n; eq = 1; } if( cnt[i] - mx == -n+1 ){ id = i; val = 1; eq = 1; } if( cnt[i] - mn > n-1 ){ cout << -1; return 0; } if( cnt[i] - mx > -n+1 ){ cout << -1; return 0; } mx = max( mx, cnt[i] ); mn = min( mn, cnt[i] ); } if( !eq ) cout << -1; else{ int a[n] = {}; a[id] = val; for( int i = id+1; i < n; i ++ ){ a[i] = a[i-1] + d[i]; if( a[i] < 1 || a[i] > n ){ cout << 0; return 0; } } for( int i = id-1; i >= 0; i -- ){ a[i] = a[i+1] - d[i+1]; if( a[i] < 1 || a[i] > n ){ cout << 0; return 0; } } for( int i = 0; i < n; i ++ ){ cout << a[i] << ' '; }cout << endl; } }
#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...