답안 #262879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262879 2020-08-13T10:27:19 Z FutymyClone Labels (NOI20_labels) C++14
25 / 100
156 ms 26744 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 5;

int n, d[N], a[N];
long long f[N];
map <long long, int> mm;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n - 1; i++) cin >> d[i], f[i] = f[i - 1] + d[i];
    mm[f[0]] = 0;
    pair <int, int> temp = make_pair(-1, -1);

    for (int i = 1; i <= n; i++) {
        if (mm.count(f[i] - (n - 1))) {
            temp = make_pair(mm[f[i] - (n - 1)] + 1, i + 1);
            break;
        }

        mm[f[i]] = i;
    }

    if (temp.first == -1) return cout << -1 << "\n", 0;
    a[temp.first] = 1, a[temp.second] = n;
    for (int i = temp.first + 1; i < temp.second; i++) a[i] = d[i - 1] + a[i - 1];
    for (int i = temp.first - 1; i >= 1; i--) a[i] = a[i + 1] - d[i];
    for (int i = temp.second + 1; i <= n; i++) a[i] = a[i - 1] + d[i - 1];
    for (int i = 1; i <= n - 1; i++) if (a[i + 1] - a[i] != d[i]) return cout << -1 << "\n", 0;
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Incorrect 1 ms 384 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Incorrect 1 ms 384 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 146 ms 26412 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 156 ms 26744 KB Output is correct
4 Correct 24 ms 4480 KB Output is correct
5 Correct 42 ms 4600 KB Output is correct
6 Correct 109 ms 14072 KB Output is correct
7 Correct 94 ms 13944 KB Output is correct
8 Correct 36 ms 4608 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Incorrect 1 ms 384 KB Output isn't correct
19 Halted 0 ms 0 KB -