답안 #946235

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946235 2024-03-14T12:40:31 Z Captain_Georgia Labels (NOI20_labels) C++17
25 / 100
137 ms 18772 KB
#include <bits/stdc++.h>
using namespace std;

#define file \
            freopen("in.txt" , "r" , stdin); \
            freopen("out.txt" , "w" , stdout);

typedef long long ll;

const int mod = 998244353;

void test_case () {
    int n;
    cin >> n;
    int dif[n - 1] , a[n];
    a[0] = 1;
    set<int> s;
    s.insert(1);
    for (int i = 0;i < n - 1;i ++) {
        cin >> dif[i];
        a[i + 1] = a[i] + dif[i];
        s.insert(a[i + 1]);
    }
    if (s.size() < n || (*s.begin() < 1 && *s.rbegin() > n)) {
        cout << "-1\n";
        return;
    }
    if (*s.begin() < 1) {
        int tmp = 1 - *s.begin();
        for (int i = 0;i < n;i ++) {
            a[i] += tmp;
            cout << a[i] << " ";
        }
        cout << "\n";
    }
    else if (*s.rbegin() > n) {
        int tmp = *s.rbegin() - n;
        for (int i = 0;i < n;i ++) {
            a[i] -= tmp;
            cout << a[i] << " ";
        }
        cout << "\n";
    }
    else {
        for (int i = 0;i < n;i ++) {
            cout << a[i] << " ";
        }
        cout << "\n";
    }
}

int32_t main () {

    ///  file
    int TIME = clock();

    int t = 1;
    ///    cin >> t;

    while (t --) {
        test_case();
    }

    cerr << "\nTime elapsed: " << (clock() - TIME) * 1000.0 / CLOCKS_PER_SEC << " ms\n";

}

Compilation message

Labels.cpp: In function 'void test_case()':
Labels.cpp:24:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if (s.size() < n || (*s.begin() < 1 && *s.rbegin() > n)) {
      |         ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 18772 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 137 ms 18764 KB Output is correct
4 Correct 38 ms 2652 KB Output is correct
5 Correct 47 ms 3532 KB Output is correct
6 Correct 85 ms 10580 KB Output is correct
7 Correct 74 ms 10276 KB Output is correct
8 Correct 60 ms 3408 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -