| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1139752 | Kerim | Permutation Recovery (info1cup17_permutation) | C++20 | 1095 ms | 2880 KiB | 
#include "bits/stdc++.h"
using namespace std;
vector<int>mods{(int) 1e9 + 7, 998244353};
struct Int {
    vector<int> val;
    Int(string s = "") {
        for (auto& mod : mods) {
            int ans = 0;
            for (auto& c : s) {
                ans = (ans * 10ll + c - '0') % mod;
            }
            val.push_back(ans);
        }
    }
    Int& operator+=(const Int& other) {
        for (int i = 0; i < (int) mods.size(); i++) {
            val[i] += other.val[i];
            if (val[i] >= mods[i]) {
                val[i] -= mods[i];
            }
        }
        return *this;
    }
    Int& operator-=(const Int& other) {
        for (int i = 0; i < (int) mods.size(); i++) {
            val[i] -= other.val[i];
            if (val[i] < 0) {
                val[i] += mods[i];
            }
        }
        return *this;
    }
    bool operator==(const Int& other) const {
        return val == other.val;
    }
};
const int N = 7e4+4;
int P[N], A[N];
int main(){
    // freopen("file.in", "r", stdin);
    int n;
    scanf("%d", &n);
    vector<Int> Q(n);
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        Q[i] = Int(s);
    }
    for (int i = n-1; i > 0; i--)
        Q[i] -= Q[i-1];
    vector<int> A;
    for (int i = 0; i < n; i++){
        Int cur("1");
        for (int j = 0; j <= (int)A.size(); j++){
            if (cur == Q[i]){
                A.insert(A.begin()+j, i);
                break;
            }
            cur += Q[A[j]];
        }
        A.push_back(i);
    }
    for (int i = 0; i < n; i++)
        P[A[i]] = i + 1;
    for (int i = 0; i < n; i++)
        printf("%d ", P[i]);
    puts("");
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
