fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define nl "\n"
  5. #define OO 0x3f3f3f3f
  6. using namespace std;
  7. const int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
  8. const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
  9. const int N = 1e5 + 5, M = 2e5 + 5;
  10. void ta2to2a()
  11. {
  12. ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr);
  13. #ifndef ONLINE_JUDGE
  14. freopen("input.txt", "r", stdin);
  15. freopen("output.txt", "w", stdout);
  16. #endif
  17. }
  18. void solve()
  19. {
  20. int n, k;
  21. cin >> n >> k;
  22. vector<ll> a(n);
  23. for (int i = 0; i < n; i++)
  24. {
  25. cin >> a[i];
  26. }
  27. vector<ll> suff(n + 1);
  28. suff[n] = 0;
  29. for (int i = n - 1; i >= 0; i--)
  30. {
  31. suff[i] = a[i] + suff[i + 1] - (i + k + 1 <= n ? suff[i + k + 1] : 0);
  32. }
  33. for (int i = 0; i <= n; i++)
  34. {
  35. cout << suff[i] << " ";
  36. }
  37. cout << nl;
  38. ll turns = 0;
  39. for (int i = 0; i <= n; i++)
  40. {
  41. turns += suff[i];
  42. }
  43. cout << turns << " ";
  44. if (turns % 2 == 0)
  45. {
  46. cout << "Bob" << nl;
  47. }
  48. else
  49. {
  50. cout << "Alice" << nl;
  51. }
  52. }
  53. int main()
  54. {
  55. ta2to2a();
  56. int t = 1;
  57. cin >> t;
  58. while (t--)
  59. {
  60. solve();
  61. }
  62. }
Success #stdin #stdout 0s 548KB
stdin
Standard input is empty
stdout
0 0 
0 Bob