# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
643863 | WeetHet | Permutation Recovery (info1cup17_permutation) | C++17 | 2387 ms | 116976 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* author: WeetHet
* created: 18.09.22 17:53:35
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include "bits/stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
constexpr ll MOD = 323102415747173;
constexpr int MAX_N = 7e4 + 5, B = 333;
unordered_multiset<ll> bk[B];
ll p[MAX_N], delta[MAX_N], aux[MAX_N], add[B];
ll mod(ll x) {
return x - (x >= MOD) * MOD;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin.exceptions(ios::failbit);
int n;
cin >> n;
ll last = 0;
rep(i, 0, n) {
string s;
cin >> s;
ll cur = 0;
for (auto c: s)
cur = (cur * 10 + c - '0') % MOD;
delta[i] = mod(cur - last + MOD);
last = cur;
}
rep(i, 0, n) {
bk[i / B].insert(delta[i]);
aux[i] = delta[i];
}
rep(T, 1, n + 1) {
int bl = (n - 1) / B;
while (bl >= 0) {
ll cur = mod(add[bl] + 1);
if (bk[bl].find(cur) != bk[bl].end()) break;
bl -= 1;
}
int pos;
for (pos = min(n - 1, (bl + 1) * B - 1); pos >= bl * B; pos--) {
if (p[pos] != 0) continue;
ll cur = mod(aux[pos] - add[bl] + MOD);
if (cur == 1) break;
}
p[pos] = T;
bk[bl].erase(bk[bl].find(aux[pos]));
for (int j = pos + 1; j < min(n, (bl + 1) * B); j++) {
if (p[j] != 0) continue;
bk[bl].erase(bk[bl].find(aux[j]));
aux[j] = mod(aux[j] - delta[pos] + MOD);
bk[bl].insert(aux[j]);
}
bl += 1;
while (bl < (n - 1) / B) {
add[bl] = mod(add[bl] + delta[pos]);
bl += 1;
}
for (int j = bl * B; j < n; j++) {
if (p[j] != 0) continue;
bk[bl].erase(bk[bl].find(aux[j]));
aux[j] = mod(aux[j] - delta[pos] + MOD);
bk[bl].insert(aux[j]);
}
}
rep(i, 0, n) cout << p[i] << ' ';
cout << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |