답안 #389326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
389326 2021-04-14T03:00:43 Z abc864197532 Permutation Recovery (info1cup17_permutation) C++17
25 / 100
2 ms 460 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define test(x) cout << #x << ' ' << x << endl
#define printv(x) { \
    for (auto a : x) cout << a << ' '; \
    cout << endl; \
}
#define pii pair<int, int>
#define pll pair<lli, lli>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int N = 512, abc = 864197532;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector <lli> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    /*
     * 1 3 5 9 11 21
     * d -> 1 2 2 4 2 10
     * p -> 1 X X X X X
     * d -> 0 1 1 3 1 9
     * p -> 1 X X X 2 X
     * d -> 0 1 1 3 1 7
     * p -> 1 X 3 X 2 X
     * d -> 0 1 1 1 1 5
     */
    vector <lli> d(n, 0), p(n, 0);
    int now = 1;
    for (int i = 0; i < n; ++i) d[i] = (i ? a[i] - a[i - 1] : a[i]);
    vector <lli> cur = d;
    while (now <= n) {
        int i;
        for (i = n - 1; ~i; --i) {
            if (!p[i] && cur[i] == 1) break;
        }
        p[i] = now++;
        for (int j = i + 1; j < n; ++j) if (!p[j]) {
            cur[j] -= d[i];
        }
    }
    printv(p);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -