Advertisement
7oSkaaa

Untitled

Oct 3rd, 2023
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
  6. #define cout_2d(vec, n, m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] << " "; j++);
  7. #define fixed(n) fixed << setprecision(n)
  8. #define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  9. #define fill(vec, value) memset(vec, value, sizeof(vec));
  10. #define mul_mod(a, b, m) (((a % m) * (b % m)) % m)
  11. #define add_mod(a, b, m) (((a % m) + (b % m)) % m)
  12. #define all(vec) vec.begin(), vec.end()
  13. #define rall(vec) vec.rbegin(), vec.rend()
  14. #define sz(x) int(x.size())
  15. #define debug(x) cout << #x << ": " << (x) << "\n";
  16. #define fi first
  17. #define se second
  18. #define ll long long
  19. #define ull unsigned long long
  20. #define Mod  1'000'000'007
  21. #define OO 2'000'000'000
  22. #define EPS 1e-9
  23. #define PI acos(-1)
  24. template < typename T = int > using Pair = pair < T, T >;
  25. vector < string > RET = {"NO", "YES"};
  26.  
  27. template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
  28.     for (auto &x : v) in >> x;
  29.     return in;
  30. }
  31.  
  32. template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
  33.     for (const T &x : v) out << x << ' ';
  34.     return out;
  35. }
  36.  
  37. vector < vector < int > > dp;
  38.  
  39. int get_ans(int x, int y){
  40.     if(x <= 0) return 0;
  41.     int& ret = dp[x][y];
  42.     if(~ret) return ret;
  43.     if(x < y) return 0;
  44.     set < int > st;
  45.     for(int i = 1; i <= x; i++){
  46.         int end = i + y - 1;
  47.         if(end > x) continue;
  48.         st.insert(get_ans(i - 1, y) ^ get_ans(x - end, y));
  49.     }
  50.     ret = 0;
  51.     while(st.count(ret)) ret++;
  52.     return ret;
  53. }
  54.  
  55. void Solve(){
  56.     int n, k;
  57.     cin >> n >> k;
  58.     dp = vector < vector < int > > (n + 1, vector < int > (k + 1, -1));
  59.     cout << (get_ans(n, k) ? "Winning" : "Losing") << "\n";
  60. }
  61.  
  62. int main(){
  63.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  64.     int t = 1;
  65.     cin >> t;
  66.     for(int tc = 1; tc <= t; tc++){
  67.         cout << "Case " << tc << ": ";
  68.         Solve();
  69.     }
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement