QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745098 | #8166. Almost Large | ucup-team3215 | WA | 3ms | 6732kb | C++20 | 1.2kb | 2024-11-14 04:10:46 | 2024-11-14 04:10:47 |
Judging History
answer
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
constexpr int L = 12, H = 2, N = pow(3, L), M = pow(3, H);
int vis[N], vis2[2][L][N];
vector<int> s[2][N];
template <int p, bool c>
inline void iter(int v, int u, int k, auto f) {
if (!p) return f(v, k);
if (c && vis2[k][(p > 1) + (p > 3) + (p > 9) + (p > 27) + (p > 81) + (p > 243) + (p > 729) + (p > 2187)][v + u]++) return;
for (int t = 3; t--; ) if (int d = (v / p % 3 < t) + k; d < 2) iter<p / 3, c>(v - (v / p % 3 - t) * p, u, d, f);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector<int> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
iter<M / 3, 0>(v[i] % M, -1, 0, [&](int u, int k) { s[k][v[i] / M * M + u].push_back(i); });
}
vector<int> q{0};
vis[0] = 1;
for (int i = 0; i < q.size() && !vis[n - 1]; ++i) if (auto tmp = v[q[i]] % M; 1) iter<N / M / 3, 1>(N / M - 1 - v[q[i]] / M, tmp * (N / M), 0, [&](int u, int k) {
u = (N / M - 1 - u) * M + tmp;
for (int d = 0; d + k < 2; ++d) while (s[d][u].size()) {
auto j = s[d][u].back();
s[d][u].pop_back();
if (!vis[j]) vis[j] = 1, q.push_back(j);
}
});
cout << (vis[n - 1]? "Yes": "No");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 6732kb
input:
2 21 14
output:
No
result:
wrong answer expected YES, found NO