Advertisement
Korotkodul

N2 stress OK

Oct 25th, 2022 (edited)
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.39 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. #include <ctime>
  13. using namespace std;
  14. using ll = long long;
  15. using ld = long double;
  16. using db = double;
  17. void cv(vector <int> &v) {
  18.     for (auto x : v) cout << x << ' ';
  19.     cout << "\n";
  20. }
  21.  
  22. void cvl(vector <ll> &v) {
  23.     for (auto x : v) cout << x << ' ';
  24.     cout << "\n";
  25. }
  26.  
  27.  
  28. void cvv(vector <vector <int> > &v) {
  29.     for (auto x : v) cv(x);
  30.     cout << "\n";
  31. }
  32.  
  33. void cvb(vector <bool> v) {
  34.     for (bool x : v) cout << x << ' ';
  35.     cout << "\n";
  36. }
  37.  
  38. void cvs(vector <string>  v) {
  39.     for (auto a : v) {
  40.         cout << a << "\n";
  41.     }
  42. }
  43.  
  44. void cvp(vector <pii> a) {
  45.     for (auto p : a) {
  46.         cout << p.first << ' ' << p.second << "\n";
  47.     }
  48.     cout << "\n";
  49. }
  50.  
  51.  
  52. bool sh = 0;
  53.  
  54. int n, m;
  55.  
  56. int dull() {
  57.     int mx = -1;
  58.     vector <vector <int> > a(n, vector <int> (m, -1));
  59.     for (int i = 0; i < n; ++i) {
  60.         for (int j = 0; j < m; ++j) {
  61.             int x = min(i, n - 1 - i), y = min(j, m - 1 - j);
  62.             a[i][j] = min(x, y);
  63.             mx = max(mx, a[i][j]);
  64.         }
  65.     }
  66.     int cnt = 0;
  67.     for (int i = 0; i < n; ++i) {
  68.         for (int j = 0; j < m; ++j) {
  69.             if (a[i][j] == mx) {
  70.                 cnt++;
  71.             }
  72.         }
  73.     }
  74.  
  75.     cvv(a);
  76.     return cnt;
  77. }
  78.  
  79. int my() {
  80.     if (n < m) {
  81.         swap(n, m);
  82.     }
  83.     if (min(n, m) <= 2) {
  84.         return n * m;
  85.     }
  86.     int dm = m / 2 - 1, k = 2;
  87.     if (m % 2 == 1) {
  88.         dm = m / 2;
  89.         k = 1;
  90.     }
  91.     int ans = (n - 2 * dm) * k;
  92.     return ans;
  93. }
  94.  
  95. bool random = 1;
  96.  
  97. int main() {
  98.     /*ios::sync_with_stdio(0);
  99.     cin.tie(0);
  100.     cout.tie(0);*/
  101.     srand(time(0));
  102.     if (!random) {
  103.             cin >> n >> m;
  104.     }
  105.     if (random) {
  106.         while (1) {
  107.             n = rand() % 100 + 1;
  108.             m = rand() % 100 + 1;
  109.             int me = my();
  110.             int he = dull();
  111.             if (me == he) {
  112.                 cout << "OK\n";
  113.             }
  114.             else {
  115.                 cout << "WA\n";
  116.                 cout << "n m = " << n << ' ' << m << "\n";
  117.                 cout << "me he = " << me << ' '<< he << "\n";
  118.                 break;
  119.             }
  120.             break;
  121.         }
  122.     }
  123.  
  124. }
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement