QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#316765#8166. Almost Largeucup-team992#WA 0ms3824kbC++201.7kb2024-01-28 03:28:322024-01-28 03:28:32

Judging History

你现在查看的是最新测评结果

  • [2024-01-28 03:28:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-01-28 03:28:32]
  • 提交

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