# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
576304 | eecs | Weird Numeral System (CCO21_day1problem2) | C++17 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// https://dmoj.ca/src/3641806
#include <bits/stdc++.h>
using namespace std;
const int S = 5005;
typedef long long ll;
int k, q, d, m;
int a[5010], b[85];
bitset < 10010 > dp[85];
inline void rmain() {
int qwq = (m + k) / (k - 1);
ll n;
scanf("%lld", &n);
ll tmp = n;
const int l = 80;
for (int i = 1; i <= l; i++) b[i] = tmp % k, tmp /= k;
dp[0][0 + S] = 1;
for (int i = 1; i <= l; i++) {
dp[i].reset();
bitset < 10010 > cur;
for (int j = 1; j <= d; j++) cur |= (a[j] >= 0 ? dp[i - 1] << a[j] : dp[i - 1] >> -a[j]);
for (int j = -qwq; j <= qwq; j++) {
dp[i][j + S] = abs(j * k + b[i]) <= qwq + m ? cur[j * k + b[i] + S] : 0;
}
}
tmp = n;
for (int i = 1; i <= l; i++) {
tmp /= k;
if (abs(tmp) <= qwq && dp[i][tmp + S]) {
for (int cur = i, rest = tmp; cur; cur--) {
rest = rest * k + b[cur];
for (int j = 1; j <= d; j++) {
int to = rest - a[j];
if (abs(to) <= qwq && dp[cur - 1][to + S]) {
rest = to;
printf("%d%c", a[j], " \n"[cur == 1]);
break;
}
}
}
return;
}
}
puts("IMPOSSIBLE");
}
int main() {
scanf("%d%d%d%d", &k, &q, &d, &m);
for (int i = 1; i <= d; i++) scanf("%d", a + i);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |