Weird verdict by the Grader
Incorrect answer on sample input case ā details below
Your output file photo.out: 3 1 5 2 4
The correct answer: 3 1 5 2 4
problem http://www.usaco.org/index.php?page=viewproblem2&cpid=988
My code
int N; cin >> N;
vector<int> b(N-1);
for(auto &w : b) cin >> w;
vector<int> ans(N);
for(int i = 0; i < N; i++){
ans[i] = N - i;
}
vector<int> v;
set<int> ss;
for(int i = 1; i <= N; i++){
v.push_back(i);
ss.insert(i);
for(int j = 1; j < N; j++){
int bck = v.back();
v.push_back(b[j - 1] - bck);
ss.insert(b[j - 1] - bck);
}
if((int)ss,size() == N) ans = min(ans, v);
v.clear();
ss.clear();
}
for(int i = 0; i < N; i++) cout << ans[i] << " ";
Why Iām getting this ā¦? help please