Submission #284851

# Submission time Handle Problem Language Result Execution time Memory
284851 2020-08-28T06:50:24 Z Ronin13 Labels (NOI20_labels) C++14
0 / 100
27 ms 1272 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
 
using namespace std;
int d[100001];
int n;
int a[100001];
int cnt=0;
vector<vector<int> >ans;
void rec(int ind,int val,vector<int>k){
	if(ind==n){
		k.pb(val);
		ans.pb(k);
		cnt++;
		return;
	}
	k.pb(val);
	for(int i=1;i<=n;i++){
		if(i-val==d[ind])rec(ind+1,i,k);
	}
}

int main(){
	cin>>n;
	
	for(int i=1;i<n;i++)cin>>d[i];

	
	for(int i=1;i<=n;i++){
		vector<int>k;
		k.pb(i);
		for(int j=2;j<=n;j++){			
			k.pb(k[(int)k.size()-1]+d[j-1]);
		}
		bool ind=true;
		for(int j=0;j<k.size();j++){
			if(k[j]<0||k[j]>n){
				ind=false;
				break;
			}
		}
		if(ind)ans.pb(k);
	}
	if(ans.size()!=1){
		cout<<-1;
		return 0;
	}
	for(int i=0;i<ans[0].size();i++)cout<<ans[0][i]<<' ';
	return 0;
}

Compilation message

Labels.cpp: In function 'int main()':
Labels.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int j=0;j<k.size();j++){
      |               ~^~~~~~~~~
Labels.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(int i=0;i<ans[0].size();i++)cout<<ans[0][i]<<' ';
      |              ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 1272 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -