Submission #55606557
Source Code Expand
// {{{
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#define debug(x...)
#define debug_arr(x...)
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// }}}
const int N = 111;
const int mod = 998244353;
int n;
LL a[N];
LL b[N];
LL dp[N][N];
LL ans[N];
int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif
cin.tie(0)->sync_with_stdio(0);
while (cin >> n)
{
for (int i = 1; i <= n; ++i) cin >> a[i];
clr(ans, 0);
ans[1] = n;
// set<LL> ds, as;
// ds.clear(), as.clear();
// for (int i = 1; i <= n; i++)
//{
// as.insert(a[i]);
// for (int j = i + 1; j <= n; j++) ds.insert(a[j] - a[i]);
//}
// vector<LL> dd = vector<LL>(all(ds));
// vector<LL> aa = vector<LL>(all(as));
set<pair<LL, LL>> st;
for (int p = 1; p <= n; p++)
{
for (int q = p + 1; q <= n; q++)
{
LL a1 = a[p];
LL d = a[q] - a[p];
if (st.find({a1, d}) != st.end()) continue;
st.insert({a1, d});
for (int j = 1; j <= n; j++) b[j] = a1 + (j - 1) * d;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= n; j++) dp[i][j] = 0;
for (int i = 0; i <= n; i++) dp[i][0] = 1;
// n^2
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
if (a[i] == b[j]) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod;
}
}
for (int ll = 2; ll <= n; ll++) ans[ll] = (ans[ll] + dp[n][ll]) % mod;
}
}
for (int i = 1; i <= n; i++)
{
cout << ans[i] << " ";
}
cout << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Count Arithmetic Subsequences |
| User | mickeyandkaka |
| Language | C++ 20 (gcc 12.2) |
| Score | 475 |
| Code Size | 2243 Byte |
| Status | AC |
| Exec Time | 35 ms |
| Memory | 3844 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 475 / 475 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3452 KiB |
| 00_sample_02.txt | AC | 1 ms | 3508 KiB |
| 00_sample_03.txt | AC | 1 ms | 3632 KiB |
| 01_random_01.txt | AC | 1 ms | 3556 KiB |
| 01_random_02.txt | AC | 2 ms | 3572 KiB |
| 01_random_03.txt | AC | 2 ms | 3588 KiB |
| 01_random_04.txt | AC | 2 ms | 3496 KiB |
| 01_random_05.txt | AC | 1 ms | 3524 KiB |
| 01_random_06.txt | AC | 35 ms | 3772 KiB |
| 01_random_07.txt | AC | 1 ms | 3436 KiB |
| 01_random_08.txt | AC | 34 ms | 3780 KiB |
| 01_random_09.txt | AC | 1 ms | 3492 KiB |
| 01_random_10.txt | AC | 35 ms | 3760 KiB |
| 01_random_11.txt | AC | 17 ms | 3712 KiB |
| 01_random_12.txt | AC | 34 ms | 3780 KiB |
| 01_random_13.txt | AC | 4 ms | 3664 KiB |
| 01_random_14.txt | AC | 35 ms | 3844 KiB |
| 01_random_15.txt | AC | 23 ms | 3732 KiB |
| 01_random_16.txt | AC | 34 ms | 3716 KiB |
| 01_random_17.txt | AC | 24 ms | 3800 KiB |
| 01_random_18.txt | AC | 35 ms | 3784 KiB |
| 01_random_19.txt | AC | 9 ms | 3580 KiB |
| 01_random_20.txt | AC | 35 ms | 3776 KiB |
| 02_handmade_01.txt | AC | 1 ms | 3568 KiB |
| 02_handmade_02.txt | AC | 1 ms | 3516 KiB |
| 02_handmade_03.txt | AC | 34 ms | 3748 KiB |
| 02_handmade_04.txt | AC | 35 ms | 3832 KiB |
| 02_handmade_05.txt | AC | 34 ms | 3836 KiB |
| 02_handmade_06.txt | AC | 34 ms | 3636 KiB |