Advertisement
Mirbek

ПИКСЕЛДЕР

Jan 18th, 2022
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int x[3], y[3], a[3], b[3];
  6. map < pair <int, int>, int > mp;
  7.  
  8. int main(){
  9.     ios::sync_with_stdio(0);
  10.  
  11.     cin >> x[0] >> y[0] >> a[0] >> b[0];
  12.     cin >> x[1] >> y[1] >> a[1] >> b[1];
  13.     cin >> x[2] >> y[2] >> a[2] >> b[2];
  14.  
  15.     while (true) {
  16.         mp[{x[0], y[0]}] = 1;
  17.         if (a[0] == x[0] && b[0] == y[0]) break;
  18.         if (x[0] < a[0])
  19.             x[0]++;
  20.         if (x[0] > a[0])
  21.             x[0]--;
  22.         if (y[0] < b[0])
  23.             y[0]++;
  24.         if (y[0] > b[0])
  25.             y[0]--;
  26.     }
  27.     while (true) {
  28.         mp[{x[1], y[1]}] = 2;
  29.         if (a[1] == x[1] && b[1] == y[1]) break;
  30.         if (x[1] < a[1])
  31.             x[1]++;
  32.         if (x[1] > a[1])
  33.             x[1]--;
  34.         if (y[1] < b[1])
  35.             y[1]++;
  36.         if (y[1] > b[1])
  37.             y[1]--;
  38.     }
  39.     while (true) {
  40.         mp[{x[2], y[2]}] = 1;
  41.         if (a[2] == x[2] && b[2] == y[2]) break;
  42.         if (x[2] < a[2])
  43.             x[2]++;
  44.         if (x[2] > a[2])
  45.             x[2]--;
  46.         if (y[2] < b[2])
  47.             y[2]++;
  48.         if (y[2] > b[2])
  49.             y[2]--;
  50.     }
  51.  
  52.     int yellow = 0, red = 0;
  53.     for (auto x : mp) {
  54.         if (x.second == 1)
  55.             yellow++;
  56.         else
  57.             red++;
  58.     }
  59.  
  60.     cout << yellow << " " << red << endl;
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement