QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569677#8790. First BillionHTensorCompile Error//C++142.6kb2024-09-17 04:33:002024-09-17 04:33:01

Judging History

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

  • [2024-09-17 04:33:01]
  • 评测
  • [2024-09-17 04:33:00]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<random>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x  << ": " << x << "\n"
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
using ll = long long;
// const int inf = 0x3f3f3f3f3f3f3f3fLL;

const int mod = 1e5;

void solve() {
    int n; cin >> n;
    vector<int> ori(n + 1);
    vector<pair<int, int>> a(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> ori[i];
        a[i].first = ori[i] % mod;
        a[i].second = i;
    }

    if(n == 2) {
        cout << (ll) 1e9 << "\n";
        return ;
    }

    vector<int> ans;
    mt19937 rng(19260817);
    auto check = [&]() {
        shuffle(a.begin() + 1, a.end(), rng);
        vector dp(n + 1, vector<int> (mod + 1));
        vector fr(n + 1, vector<pair<int, int>>(mod + 1));
        ans.clear();
        int sum = 0;

        auto positive = [](int x) {
            int t = x % mod;
            if(t < 0) return t + mod;
            return t;
        };

        for(int i = 1; i <= n; i++) {
            for(int j = 0; j < mod; j++) {
                int last = positive(j - a[i].first);
                if(dp[i - 1][j]) {
                    dp[i][j] = dp[i - 1][j];
                    fr[i][j] = fr[i - 1][j];
                } else if(dp[i - 1][last]) {
                    dp[i][j] = dp[i - 1][last];
                    fr[i][j] = {i - 1, last};
                }
            }

            if(dp[i][0]) {
                ans.push_back(a[i].second);
                auto [ii, ij] = fr[i][0];
                while(pair(ii, ij) != pair(0LL, 0LL)) {
                    ans.push_back(a[ii].second);
                    int nii = fr[ii][ij].first, njj = fr[ii][ij].second;
                    ii = nii, ij = njj;
                }
                break;
            }
            dp[i][a[i].first] = 1;
        }

        for(auto i : ans) {
            sum += ori[i];
        }

        if(sum != (long long)1e9) {
            return false;
        }
        return true;
    };

    while(!check()) {
        continue;
    }

    cout << ans.size() << " ";
    for(auto i : ans) {
        cout << i << " ";
    }
    cout << "\n";
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int T = 1;
    while(T--) solve();
    return 0;
}

/*

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

*/

Details

answer.code:13:12: error: ‘array’ does not name a type
   13 | using a3 = array<int, 3>;
      |            ^~~~~
answer.code: In lambda function:
answer.code:38:16: error: missing template arguments before ‘dp’
   38 |         vector dp(n + 1, vector<int> (mod + 1));
      |                ^~
answer.code:39:16: error: missing template arguments before ‘fr’
   39 |         vector fr(n + 1, vector<pair<int, int>>(mod + 1));
      |                ^~
answer.code:52:20: error: ‘dp’ was not declared in this scope; did you mean ‘dd’?
   52 |                 if(dp[i - 1][j]) {
      |                    ^~
      |                    dd
answer.code:54:21: error: ‘fr’ was not declared in this scope
   54 |                     fr[i][j] = fr[i - 1][j];
      |                     ^~
answer.code:57:21: error: ‘fr’ was not declared in this scope
   57 |                     fr[i][j] = {i - 1, last};
      |                     ^~
answer.code:61:16: error: ‘dp’ was not declared in this scope; did you mean ‘dd’?
   61 |             if(dp[i][0]) {
      |                ^~
      |                dd
answer.code:63:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   63 |                 auto [ii, ij] = fr[i][0];
      |                      ^
answer.code:63:33: error: ‘fr’ was not declared in this scope
   63 |                 auto [ii, ij] = fr[i][0];
      |                                 ^~
answer.code:64:27: error: missing template arguments before ‘(’ token
   64 |                 while(pair(ii, ij) != pair(0LL, 0LL)) {
      |                           ^
answer.code:64:43: error: missing template arguments before ‘(’ token
   64 |                 while(pair(ii, ij) != pair(0LL, 0LL)) {
      |                                           ^
answer.code:67:36: error: ‘njj’ was not declared in this scope
   67 |                     ii = nii, ij = njj;
      |                                    ^~~
answer.code:71:13: error: ‘dp’ was not declared in this scope; did you mean ‘dd’?
   71 |             dp[i][a[i].first] = 1;
      |             ^~
      |             dd