QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676450 | #8790. First Billion | caustique | RE | 1ms | 3944kb | C++17 | 1.6kb | 2024-10-25 21:35:38 | 2024-10-25 21:35:38 |
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;
long long sum(const vector<int>& a, const vector<int>& idx) {
long long sum = 0;
REP(i, SZ(idx)) {
sum += a[idx[i] - 1];
}
return sum;
}
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 = 2347;
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';
assert(sum(a, res) == 1'000'000'000);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3944kb
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: 0
Accepted
time: 1ms
memory: 3596kb
input:
10 119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836
output:
5 9 8 6 5 2
result:
ok OK (n = 10)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
14 384615281 84612238 83310504 54746763 142296081 56775470 128760350 343006424 177232390 214368720 67220468 21895072 16352717 224807522
output:
7 13 12 10 9 7 6 1
result:
ok OK (n = 14)
Test #4:
score: -100
Runtime Error
input:
14 270208635 14270307 89661499 113578022 47687195 101043954 38775146 208193324 650676076 351701957 3427619 59535626 24230888 27009752