# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
633848 | gs14004 | Weird Numeral System (CCO21_day1problem2) | C++17 | 7 ms | 7124 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, lint>;
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const int mod = 1e9 + 7;
const int MAXT = 320005;
int k, n, m;
vector<vector<int>> a;
int Mod(lint x){
return (x % k + k) % k;
}
int dist[3 * MAXT], par[3 * MAXT];
map<lint, int> dp, path;
bool dfs(lint N){
if(abs(N) <= m){
if(dist[N + MAXT] <= 1e7) return dp[N] = true;
return dp[N] = false;
}
lint modv = Mod(N);
if(sz(a[modv]) == 0) return dp[N] =false;
for(auto &x : a[modv]){
if(dfs((N - x) / k)){
path[N] = x;
return dp[N] = true;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |