# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97259 | 2019-02-14T16:14:12 Z | popovicirobert | Permutation Recovery (info1cup17_permutation) | C++14 | 34 ms | 452 KB |
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull long long #define ld long double // 217 // 44 using namespace std; const int MOD1 = 666013; const int MOD2 = 666019; const int MAXN = 70000; ull dif[MAXN + 1], aux[MAXN + 1]; string str; const int B = 300; unordered_multiset <ull> fr[MAXN / B]; ull lazy[MAXN / B]; int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, j, n; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; ull last = 0; for(i = 0; i < n; i++) { cin >> str; ull cur = 0; for(auto it : str) { cur = cur * 10 + it - '0'; } dif[i] = cur - last; last = cur; } for(i = 0; i < n; i++) { fr[i / B].insert(dif[i]); aux[i] = dif[i]; } vector <int> sol(n); for(int tt = 1; tt <= n; tt++) { i = (n - 1) / B; while(i > 0) { if(fr[i].find(1 + lazy[i]) != fr[i].end()) { break; } i--; } int pos; for(j = min(n - 1, (i + 1) * B - 1); j >= i * B; j--) { if(sol[j]) { continue; } if(aux[j] + lazy[i] == 1) { pos = j; break; } } sol[pos] = tt; for(j = pos; j < min(n, (i + 1) * B); j++) { fr[i].erase(fr[i].find(aux[j])); aux[j] -= dif[pos]; fr[i].insert(aux[j]); } i++; while(i < (n - 1) / B) { lazy[i] += dif[pos]; i++; } for(j = i * B; j < n; j++) { fr[i].erase(fr[i].find(aux[j])); aux[j] -= dif[pos]; fr[i].insert(aux[j]); } } for(i = 0; i < n; i++) { cout << sol[i] << " "; } //cin.close(); //cout.close(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Incorrect | 34 ms | 452 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Incorrect | 34 ms | 452 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Incorrect | 34 ms | 452 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Incorrect | 34 ms | 452 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Incorrect | 34 ms | 452 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Incorrect | 34 ms | 452 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |