QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#676439 | #8790. First Billion | caustique | WA | 0ms | 3660kb | C++17 | 1.4kb | 2024-10-25 21:32:25 | 2024-10-25 21:32:25 |
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;
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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
10 386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997
output:
5 9 7 6 5 1
result:
ok OK (n = 10)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3660kb
input:
10 119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836
output:
4 10 8 4 3
result:
wrong answer need sum 1000000000, got sum 797340332