Submission #55539974
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
int32_t main(){
int n;cin>>n;
vector<int> arr(n);
vector<int> arti;
for (int i = 0; i < n; ++i)
{
cin>>arr[i];
for (int j = 0; j < i; j++){
arti.push_back(arr[i]-arr[j]);
}
}
vector<int> ans(n);
sort(arti.begin(), arti.end());
auto it = unique(arti.begin(), arti.end());
arti.erase(it,arti.end());
for (int i = 0; i < arti.size(); i++){
vector<vector<int>> dp(n,vector<int>(n+1,0));
for (int j = 0; j < n; j++){
dp[j][1]++;
for (int k = 0; k < j; k++){
if (arr[j]-arr[k]==arti[i]){
for (int z = 2; z <= n; z++){
dp[j][z]+=dp[k][z-1];
if (dp[j][z]>=MOD) dp[j][z]-=MOD;
}
}
}
for (int k = 1; k <= n; k++){
ans[k-1]+=dp[j][k];
if (ans[k-1]>=MOD) ans[k-1]-=MOD;
}
}
}
ans[0]=n;
cout<<endl;
for (int i = 0; i < n; ++i)
{
cout<<ans[i]<<" ";
}
cout<<endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Count Arithmetic Subsequences |
| User | tolbi |
| Language | C++ 20 (gcc 12.2) |
| Score | 475 |
| Code Size | 977 Byte |
| Status | AC |
| Exec Time | 29 ms |
| Memory | 3744 KiB |
Compile Error
Main.cpp: In function ‘int32_t main()’:
Main.cpp:20:27: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
20 | for (int i = 0; i < arti.size(); i++){
| ~~^~~~~~~~~~~~~
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 | 3664 KiB |
| 00_sample_02.txt | AC | 1 ms | 3476 KiB |
| 00_sample_03.txt | AC | 1 ms | 3464 KiB |
| 01_random_01.txt | AC | 1 ms | 3496 KiB |
| 01_random_02.txt | AC | 1 ms | 3624 KiB |
| 01_random_03.txt | AC | 2 ms | 3720 KiB |
| 01_random_04.txt | AC | 1 ms | 3532 KiB |
| 01_random_05.txt | AC | 1 ms | 3484 KiB |
| 01_random_06.txt | AC | 29 ms | 3552 KiB |
| 01_random_07.txt | AC | 1 ms | 3512 KiB |
| 01_random_08.txt | AC | 29 ms | 3588 KiB |
| 01_random_09.txt | AC | 1 ms | 3456 KiB |
| 01_random_10.txt | AC | 28 ms | 3744 KiB |
| 01_random_11.txt | AC | 15 ms | 3572 KiB |
| 01_random_12.txt | AC | 28 ms | 3540 KiB |
| 01_random_13.txt | AC | 4 ms | 3544 KiB |
| 01_random_14.txt | AC | 28 ms | 3600 KiB |
| 01_random_15.txt | AC | 19 ms | 3528 KiB |
| 01_random_16.txt | AC | 29 ms | 3680 KiB |
| 01_random_17.txt | AC | 21 ms | 3732 KiB |
| 01_random_18.txt | AC | 29 ms | 3536 KiB |
| 01_random_19.txt | AC | 9 ms | 3524 KiB |
| 01_random_20.txt | AC | 29 ms | 3588 KiB |
| 02_handmade_01.txt | AC | 1 ms | 3504 KiB |
| 02_handmade_02.txt | AC | 1 ms | 3548 KiB |
| 02_handmade_03.txt | AC | 2 ms | 3744 KiB |
| 02_handmade_04.txt | AC | 2 ms | 3584 KiB |
| 02_handmade_05.txt | AC | 5 ms | 3620 KiB |
| 02_handmade_06.txt | AC | 6 ms | 3548 KiB |