QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#316765 | #8166. Almost Large | ucup-team992# | WA | 0ms | 3824kb | C++20 | 1.7kb | 2024-01-28 03:28:32 | 2024-01-28 03:28:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef int uci;
#define int long long
#define F first
#define S second
#define ar array
void solve(){
int n;
cin >> n;
int N = n; //xd
vector<int> A(n);
for(int i{}; i < n; ++i)
cin >> A[i];
vector<vector<ll>> T(N);
for(int i = 0; i < N; i++) {
int v = A[i];
for(int k = 0; k < 12; k++) {
T[i].push_back(v%3);
v /= 3;
}
//sreverse(T[i].begin(), T[i].end());
}
vector<ll> P3(12, 1);
for(int i = 1; i < 12; i++) P3[i] = 3*P3[i-1];
vector<vector<vector<pair<ll,ll>>>> sorts(3, vector<vector<pair<ll,ll>>>(12));
for(int v = 0; v < 3; v++) {
for(int p = 0; p < 12; p++) {
for(int i = 0; i < N; i++) {
if(T[i][p] == v) sorts[v][p].push_back({A[i], i});
}
sort(sorts[v][p].begin(), sorts[v][p].end());
}
}
vector<bool> alr(N, false);
vector<ll> vq; vq.push_back(0);
while(vq.size()) {
int b = vq.back(); vq.pop_back();
if(alr[b]) continue;
alr[b] = true;
for(int p = 0; p < 12; p++) {
for(int v = 0; v <= T[b][p]; v++) {
int b2 = A[b] + (T[b][p] - v)*P3[p];
/*cout << A[b] << "=>" << b2 << "\n";
cout << p << " " << v << " " << T[b][p] << endl;*/
while(sorts[v][p].size() && b2 <= sorts[v][p].back().first) {
vq.push_back(sorts[v][p].back().second); sorts[v][p].pop_back();
}
}
}
}
if(alr[N-1]) cout << "Yes\n";
else cout << "NO\n";
}
uci main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3824kb
input:
2 21 14
output:
NO
result:
wrong answer expected YES, found NO