fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. const int MOD = 998244353;
  5.  
  6. int p(int n) {
  7. if (n == 0) return 1;
  8. int x = p(n / 2);
  9. if (n % 2 == 0) return (x * x) % MOD;
  10. else return ((x * x) % MOD * 2) % MOD;
  11. }
  12.  
  13. signed main() {
  14. ios_base::sync_with_stdio(0);
  15. cin.tie(0);
  16. int t;
  17. cin >> t;
  18. int n, k;
  19. cin >> n >> k;
  20. int a[n];
  21. for (int i = 0; i < n; ++i) cin >> a[i];
  22. vector <int> vec;
  23. vec.push_back(-1);
  24. int cnt = 0;
  25. for (int i = 0; i < n; ++i) {
  26. if (a[i] > k) vec.push_back(i);
  27. else ++cnt;
  28. }
  29. vec.push_back(n);
  30. int res = 0;
  31. for (int i = 1; i < vec.size(); ++i) {
  32. int x = vec[i] - vec[i - 1] - 1;
  33. res = (res + (x * (x + 1)) / 2) % MOD;
  34. }
  35. int res2 = ((p(cnt) - 1) % MOD + MOD) % MOD;
  36. cout << res << ' ' << res2;
  37. return 0;
  38. }
Success #stdin #stdout 0s 5320KB
stdin
2
4 4
1 2 3 4
stdout
10 15