提出 #69710421
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i, j, k) for(int i = (j); i <= (k); i++)
#define per(i, j, k) for(int i = (j); i >= (k); i--)
#define pb emplace_back
#define fi first
#define se second
using vi = vector<int>;
using pi = pair<int, int>;
template<typename T0, typename T1> bool chmin(T0 &x, const T1 &y){
if(y < x){x = y; return true;} return false;
}
template<typename T0, typename T1> bool chmax(T0 &x, const T1 &y){
if(x < y){x = y; return true;} return false;
}
template<typename T> void debug(char *s, T x){
cerr << s <<" = "<< x <<endl;
}
template<typename T, typename ...Ar> void debug(char *s, T x, Ar... y){
int dep = 0;
while(!(*s == ',' && dep == 0)){
if(*s == '(') dep++;
if(*s == ')') dep--;
cerr << *s++;
}
cerr <<" = "<< x <<",";
debug(s + 1, y...);
}
#define gdb(...) debug((char*)#__VA_ARGS__, __VA_ARGS__)
using u32 = uint32_t;
using u64 = uint64_t;
constexpr int mod = 998244353;
struct mint{
u32 x;
mint(): x(0){}
mint(int _x){
_x %= mod;
if(_x < 0) _x += mod;
x = _x;
}
u32 val()const {
return x;
}
mint qpow(int y = mod - 2)const {
assert(y >= 0);
mint t = *this, res = 1;
while(y){
if(y % 2) res *= t;
t *= t;
y /= 2;
}
return res;
}
mint& operator += (const mint &B){
if((x += B.x) >= mod) x -= mod;
return *this;
}
mint& operator -= (const mint &B){
if((x -= B.x) >= mod) x += mod;
return *this;
}
mint& operator *= (const mint &B){
x = (u64)x * B.x % mod;
return *this;
}
mint& operator /= (const mint &B){
return *this *= B.qpow();
}
friend mint operator + (const mint &A, const mint &B){
return mint(A) += B;
}
friend mint operator - (const mint &A, const mint &B){
return mint(A) -= B;
}
friend mint operator * (const mint &A, const mint &B){
return mint(A) *= B;
}
friend mint operator / (const mint &A, const mint &B){
return mint(A) /= B;
}
mint operator - ()const {
return mint() - *this;
}
};
const int N = 1e6 + 5;
mint fac[N], ifac[N];
void init(){
fac[0] = ifac[0] = 1;
rep(i, 1, N - 1){
fac[i] = fac[i - 1] * i;
ifac[i] = 1 / fac[i];
}
}
mint C(int m, int n){
return fac[m] * ifac[n] * ifac[m - n];
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
init();
int l, k, n;
cin >> l >> k >> n;
vi a(n);
for(auto &x:a){
cin >> x;
}
mint ans = 0;
rep(i, 0, n - 1){
int c0 = 0, c1 = 0;
rep(j, 0, i - 1){
c0 += (a[j] + k > a[i]);
c1 += (a[i] + k - l > a[j]);
}
mint t = c0 + c1 + 2;
if(c0 == 0){
t += 1;
}
if(c1 == 0){
t += 1;
}
ans += t;
}
ans *= mint(2).qpow(n - 3 + (mod - 1));
cout << ans.val() <<'\n';
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 700 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt |
| All |
00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00-sample-001.txt |
AC |
105 ms |
11196 KiB |
| 00-sample-002.txt |
AC |
105 ms |
11264 KiB |
| 00-sample-003.txt |
AC |
105 ms |
11128 KiB |
| 00-sample-004.txt |
AC |
105 ms |
11200 KiB |
| 01-001.txt |
WA |
105 ms |
11340 KiB |
| 01-002.txt |
AC |
105 ms |
11328 KiB |
| 01-003.txt |
AC |
105 ms |
11200 KiB |
| 01-004.txt |
AC |
105 ms |
11208 KiB |
| 01-005.txt |
WA |
105 ms |
11272 KiB |
| 01-006.txt |
WA |
1819 ms |
11272 KiB |
| 01-007.txt |
TLE |
2208 ms |
11616 KiB |
| 01-008.txt |
TLE |
2212 ms |
11276 KiB |
| 01-009.txt |
AC |
997 ms |
11280 KiB |
| 01-010.txt |
TLE |
2208 ms |
11480 KiB |
| 01-011.txt |
TLE |
2208 ms |
12084 KiB |
| 01-012.txt |
TLE |
2208 ms |
12000 KiB |
| 01-013.txt |
TLE |
2208 ms |
11984 KiB |
| 01-014.txt |
TLE |
2208 ms |
11848 KiB |
| 01-015.txt |
TLE |
2212 ms |
11944 KiB |
| 01-016.txt |
TLE |
2208 ms |
11988 KiB |
| 01-017.txt |
TLE |
2208 ms |
11992 KiB |
| 01-018.txt |
TLE |
2208 ms |
12016 KiB |
| 01-019.txt |
TLE |
2208 ms |
11932 KiB |
| 01-020.txt |
TLE |
2208 ms |
11920 KiB |
| 01-021.txt |
TLE |
2208 ms |
11912 KiB |
| 01-022.txt |
TLE |
2208 ms |
11932 KiB |
| 01-023.txt |
TLE |
2208 ms |
11996 KiB |
| 01-024.txt |
TLE |
2208 ms |
12032 KiB |
| 01-025.txt |
TLE |
2208 ms |
11812 KiB |
| 01-026.txt |
TLE |
2208 ms |
11956 KiB |
| 01-027.txt |
TLE |
2208 ms |
11940 KiB |
| 01-028.txt |
TLE |
2208 ms |
11968 KiB |