Submission #1101054

# Submission time Handle Problem Language Result Execution time Memory
1101054 2024-10-15T12:41:28 Z Kirill22 Permutation Recovery (info1cup17_permutation) C++17
25 / 100
1 ms 508 KB
#include "bits/stdc++.h"

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i; i--) {
        a[i] -= a[i - 1];
    }
    vector<int> ord = {0};
    for (int i = 1; i < n; i++) {
        long long tmp = 1;
        for (int j = 0; j <= (int) ord.size(); j++) {
            if (j) {
                tmp += a[ord[j - 1]];
            }
            if (tmp == a[i]) {
                ord.insert(ord.begin() + j, i);
                break;
            }
        }
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        ans[ord[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << " ";
    }
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -