Advertisement
Korotkodul

N19_ege_2022_demo

Jan 17th, 2023 (edited)
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int, int>
  11. #define pb(x) push_back(x)
  12. using namespace std;
  13. using ll = long long;
  14. using ld = long double;
  15. using db = double;
  16. void cv(vector <int> &v) {
  17.     for (auto x : v) cout << x << ' ';
  18.     cout << "\n";
  19. }
  20.  
  21. void cvl(vector <ll> &v) {
  22.     for (auto x : v) cout << x << ' ';
  23.     cout << "\n";
  24. }
  25.  
  26.  
  27. void cvv(vector <vector <int> > &v) {
  28.     for (auto x : v) cv(x);
  29.     cout << "\n";
  30. }
  31.  
  32. void cvb(vector <bool> v) {
  33.     for (bool x : v) cout << x << ' ';
  34.     cout << "\n";
  35. }
  36.  
  37. void cvs(vector <string>  v) {
  38.     for (auto a : v) {
  39.         cout << a << "\n";
  40.     }
  41. }
  42.  
  43. void cvp(vector <pii> a) {
  44.     for (auto p : a) {
  45.         cout << p.first << ' ' << p.second << "\n";
  46.     }
  47.     cout << "\n";
  48. }
  49.  
  50.  
  51.  
  52. int main() {
  53.     ios::sync_with_stdio(0);
  54.     cin.tie(0);
  55.     cout.tie(0);
  56.     vector <vector <int> > dp(80, vector <int> (80, 100));
  57.     bool sh  = 0;
  58.     for (int j = 77; j >= 36; --j) {
  59.         for (int i = 7; i <= 77; ++i) {
  60.             dp[i][j] = 1;
  61.         }
  62.     }
  63.     for (int j = 35; j >= 0; --j) {
  64.         for (int i = 76; i >= 7; --i) {
  65.             if (sh) {
  66.                 cout << "(" << i << "," << j << ")\n";
  67.             }
  68.             if (min(i, j) + max(i, j) * 2 >= 77) {
  69.                 dp[i][j] = 1;
  70.                 if (sh) {
  71.                     cout << "ok\n";
  72.                     cout << "\n\n";
  73.                 }
  74.                 continue;
  75.             }
  76.             vector <pii> to = { {i + 1, j}, {i, j + 1}, {i, j * 2} };
  77.             int in_win = 100, in_lose = 0;
  78.             if (sh) {
  79.                 cout << "to\n";
  80.                 cvp(to);
  81.  
  82.             }
  83.             for (pii p: to) {
  84.                 int x = p.first, y = p.second;
  85.                 if (sh) {
  86.                     cout << "x y  = " << x << ' ' << y << "\n";
  87.                     cout << "dp[x][y] = " << dp[x][y] << "\n";
  88.                 }
  89.                 if (dp[x][y] < 0) {
  90.                     in_win = min(in_win, -dp[x][y] + 1);
  91.                 }
  92.                 if (dp[x][y] >= 1) {
  93.                     in_lose = -max(abs(in_lose), dp[x][y]);
  94.                 }
  95.             }
  96.             if (in_win == 100) {
  97.                 dp[i][j] = in_lose;
  98.             } else {
  99.                 dp[i][j] = in_win;
  100.             }
  101.             if (sh) {
  102.                 cout << "in_win = " << in_win << "\n";
  103.                 cout << "in_lose = " << in_lose << "\n";
  104.             }
  105.             if (sh) {
  106.                 cout << "\n\n";
  107.             }
  108.         }
  109.     }
  110.     for (int i = 7; i <= 40; ++i) {
  111.         for (int j = 30; j <= 35; ++j) {
  112.             cout << dp[i][j] << ' ';
  113.         } cout << "\n";
  114.     }
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement