QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676436#8790. First BillioncaustiqueWA 1ms3804kbC++171.5kb2024-10-25 21:31:462024-10-25 21:31:47

Judging History

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

  • [2024-10-25 21:31:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-10-25 21:31:46]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
 
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(), (a).end()
 
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    const int M = 1009;
    vector<vector<bool>> dp(n + 1, vector<bool>(M));
    vector<vector<int>> pr(n + 1, vector<int>(M, -1));
    dp[0][0] = true;
    REP(i, n) {
        REP(j, M) {
            if (!dp[i][j]) {
                continue;
            }
            dp[i + 1][j] = true;
            pr[i + 1][j] = j;
            dp[i + 1][(j + a[i]) % M] = true;
            pr[i + 1][(j + a[i]) % M] = j;
        }
    }
    const int SUM = 1e9;
    cout << dp[n][SUM % M] << endl;
    vector<int> res;
    int cur = SUM % M;
    for (int i = n; i > 0; i--) {
        int prv = pr[i][cur];
        if (prv != cur) {
            res.push_back(i);
        }
        cur = prv;
    }
    cout << SZ(res) << '\n';
    for (int r : res) cout << r << ' ';
    cout << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3804kb

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

1
5
9 7 6 5 1 

result:

wrong answer need sum 1000000000, got sum  192751270