QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#177292 | #6876. Out of Control | PPP# | AC ✓ | 19ms | 3632kb | C++17 | 1.2kb | 2023-09-12 19:56:39 | 2023-09-12 19:56:39 |
Judging History
answer
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
const int maxN = 3005;
int x[maxN];
int cnt[maxN];
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
int s = a + b;
if (s >= mod) s -= mod;
return s;
}
int mult(int a, int b) {
return (1LL * a * b) % mod;
}
int dp[maxN];
void solve() {
cin >> n;
map<int,int> mp;
for (int i = 1; i <= n; i++) {
cin >> x[i];
mp[x[i]]++;
}
int SZ = 0;
for (auto& it : mp) {
SZ++;
cnt[SZ] = it.second;
}
memset(dp, 0, sizeof dp);
dp[0] = 1;
int LIM = 0;
for (int i = 0; i < SZ; i++) {
for (int j = 1; j <= LIM + cnt[i + 1]; j++) {
dp[j] = sum(dp[j], dp[j - 1]);
}
LIM += cnt[i + 1];
}
for (int i = 1; i <= n; i++) {
cout << dp[i] << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
int tst;
cin >> tst;
while (tst--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 3632kb
input:
63 54 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 2059...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 3 6 10 15 21 28 36 45 55 66 78 91 105 ...
result:
ok 29916 lines