Advertisement
cosenza987

Untitled

Dec 18th, 2023
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. //Слава Україні, Героям слава
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     ios_base::sync_with_stdio(false);
  9.     cin.tie(nullptr);
  10.     freopen("in.txt", "r", stdin);
  11.     freopen("out.txt", "w", stdout);
  12.     string s;
  13.     vector<pair<long long, long long>> v;
  14.     v.push_back({0, 0});
  15.     long long res = 0;
  16.     while(cin >> s) {
  17.         string a, b;
  18.         cin >> a >> b;
  19.         int dx = 0, dy = 0;
  20.         if(b.back() == '0') {
  21.             dy = 1;
  22.         } else if(b.back() == '1') {
  23.             dx = 1;
  24.         } else if(b.back() == '2') {
  25.             dy = -1;
  26.         } else {
  27.             dx = -1;
  28.         }
  29.         b.pop_back();
  30.         b.erase(b.begin());
  31.         long long x = stoul(b, nullptr, 16);
  32.         res += x;
  33.         v.push_back({v.back().first + dx * x, v.back().second + dy * x});
  34.     }
  35.     int n = v.size();
  36.     long long ans = 0;
  37.     for(int i = 0; i < n; i++) {
  38.         cout << v[i].first << " " << v[i].second << "\n";
  39.         ans += v[i].first * v[(i + 1) % n].second;
  40.         ans -= v[i].second * v[(i + 1) % n].first;
  41.     }
  42.     ans = abs(ans) / 2;
  43.     cout << ans << " " << res << " " << ans + res / 2 + 1 << "\n";
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement