Manioc

jardim_de_infancia

Jun 12th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef pair<int, int> pii;
  6. pii p[8];
  7.  
  8. int dist(pii a, pii b){
  9.     int x = a.first-b.first;
  10.     int y = a.second-b.second;
  11.     return x*x + y*y;
  12. }
  13.  
  14. pii vetor(pii a,pii b){
  15.     int x = b.first-a.first;
  16.     int y = b.second-a.second;
  17.     return make_pair(x, y);
  18. }
  19.  
  20. int pe(pii a, pii b){
  21.     int val = a.first*b.first + a.second*b.second;
  22.     return val;
  23. }
  24.  
  25. int pv(pii a, pii b){
  26.     int k = a.first*b.second - a.second*b.first;
  27.     return k;
  28. }
  29.  
  30. pii pm(pii a, pii b){
  31.     int x = (a.first+b.first)/2;
  32.     int y = (a.second+b.second)/2;
  33.     return make_pair(x,y);
  34. }
  35. int main(){
  36.     for(int i = 1; i <= 7; i++) cin >> p[i].first >> p[i].second;
  37.  
  38.     int ans = true;
  39.     ans =  ans && pe(vetor(p[1], p[2]), vetor(p[1], p[3])) > 0;
  40.     //cout << ans << endl;
  41.  
  42.     ans = ans && dist(p[1], p[2]) == dist(p[1], p[3]);
  43.     //cout << ans << endl;
  44.  
  45.     ans = ans && pv(vetor(p[2], p[3]), vetor(p[4], p[5])) == 0;
  46.     //cout << ans << endl;
  47.  
  48.     ans = ans && pm(p[2],p[3]) == pm(p[4], p[5]);
  49.     //cout << ans << endl;
  50.  
  51.     ans = ans && dist(p[2], p[3]) > dist(p[4], p[5]);
  52.     //cout << ans << endl;
  53.  
  54.     ans = ans && pe(vetor(p[4], p[6]), vetor(p[2], p[3])) == 0;
  55.     ans = ans && pe(vetor(p[5], p[7]), vetor(p[2], p[3])) == 0;
  56.     //cout << ans << endl;
  57.  
  58.     ans = ans && dist(p[4], p[6]) == dist(p[5], p[7]);
  59.     //cout << ans << endl;
  60.  
  61.     ans = ans && pv(vetor(p[1], p[6]), vetor(p[2], p[3])) != 0;
  62.  
  63.     if(ans) cout << "S\n";
  64.     else cout << "N\n";
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment