-
Notifications
You must be signed in to change notification settings - Fork 0
/
photo.cpp
46 lines (41 loc) · 975 Bytes
/
photo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
freopen("photo.in", "r", stdin);
freopen("photo.out", "w", stdout);
int N; cin >> N;
int b[N-1];
for (int i=0; i<N - 1; i++) {
cin >> b[i];
}
int next;
vector<int> nexts;
for (int guess=1; guess<b[0]; guess++) {
if (N == nexts.size()) {
break;
}
nexts.clear();
next = guess;
for (int i=0; i<N; i++) {
nexts.push_back(next);
if (b[i] - next > 0) {
if (find(nexts.begin(), nexts.end(), b[i] - next) != nexts.end()) {
break;
} else {
next = b[i] - next;
}
} else {
break;
}
}
}
for (int i=0; i<N; i++) {
cout << nexts[i];
if (i < N - 1) {
cout << " ";
}
}
}