# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1102470 | Thanhs | Weird Numeral System (CCO21_day1problem2) | C++17 | 928 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}
const int NM = 5e3 + 5;
vector<int> v;
int k, q, d, m, a[NM];
bool ok;
int F(int x)
{
return ((x % k) + k) % k;
}
void dfs(int x)
{
if (v.size() && !x)
{
ok = 1;
for (int i = v.size() - 1; i >= 0; i--)
cout << v[i] << ' ';
cout << endl;
return;
}
for (int i = 1; i <= d; i++)
if (F(x) == F(a[i]))
{
v.push_back(a[i]);
dfs((x - a[i]) / k);
v.pop_back();
}
}
void solve()
{
cin >> k >> q >> d >> m;
for (int i = 1; i <= d; i++)
cin >> a[i];
while (q--)
{
int x;
cin >> x;
dfs(x);
if (!ok)
cout << "IMPOSSIBLE\n";
}
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
if (fopen("in.txt", "r"))
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
int tc = 1;
// cin >> tc;
while (tc--)
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |