QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676436 | #8790. First Billion | caustique | WA | 1ms | 3804kb | C++17 | 1.5kb | 2024-10-25 21:31:46 | 2024-10-25 21:31:47 |
Judging History
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