Advertisement
artemgf

Карты

Dec 1st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <set>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <stdio.h>
  9. #include <cmath>
  10. #include <math.h>
  11. #include <queue>
  12. #include <stack>
  13. #include <climits>
  14. #include <deque>
  15. #include <ctime>
  16.  
  17. using namespace std;
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef unsigned int ui;
  22.  
  23. #define mh() make_heap()
  24. #define poph() pop_heap()
  25. #define pushh() push_heap()
  26. #define sor(n) n.begin(), n.end()
  27. #define mp make_pair
  28. #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
  29.  
  30. #define formx(a1,b1,c1,a2,b2,c2) ((a1*c2-a2*c1)/(a1*b2-b1*a2))
  31. #define formy(a1,b1,c1,a2,b2,c2) ((c1*b2-c2*b1)/(a1*b2-b1*a2))
  32. #define forma(y1,y2) (y2-y1)
  33. #define formb(x1,x2) (x1-x2)
  34. #define formc(x1,y1,x2,y2) (x1*(y2-y1)-y1*(x2-x1))
  35. #define ras(x1,y1,x2,y2) sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
  36.  
  37. struct cord
  38. {
  39.     double x1, y1, x2, y2;
  40. };
  41. struct limcord
  42. {
  43.     double x, y;
  44.     bool good;
  45. };
  46.  
  47. bool checkparal(double a1, double a2, double b1, double b2)
  48. {
  49.     return a1 / b1 == a2 / b2;
  50. }
  51.  
  52. limcord findt(cord c, cord now)
  53. {
  54.     double a1 = forma(now.y1, now.y2);
  55.     double b1 = formb(now.x1, now.x2);
  56.     double c1 = formc(now.x1, now.y1, now.x2, now.y2);
  57.     double a2 = forma(c.y1, c.y2);
  58.     double b2 = formb(c.x1, c.x2);
  59.     double c2 = formc(c.x1, c.y1, c.x2, c.y2);
  60.  
  61.     if (!checkparal(a1, a2, b1, b2))
  62.     {
  63.         double x = formx(a1, b1, c1, a2, b2, c2);
  64.         double y = formy(a1, b1, c1, a2, b2, c2);
  65.         return{ x,y, true };
  66.     }
  67.     else
  68.     {
  69.         return{ NULL,NULL, false };
  70.     }
  71. }
  72.  
  73. bool checkT(limcord now, cord ot)
  74. {
  75.     if (ras(ot.x1, ot.y1, ot.x2, ot.y2) == ras(ot.x1, ot.y1, now.x, now.y) + ras(ot.x2, ot.y2, now.x, now.y))
  76.         return true;
  77.     else
  78.         return false;
  79. }
  80.  
  81. vector <ll> fib;
  82. void aadfib()
  83. {
  84.     fib.push_back(1);
  85.     fib.push_back(1);
  86.     for (int i = 3; i <= 1e7; i++)
  87.     {
  88.         fib.push_back(fib[i - 1] + fib[i - 2]);
  89.     }
  90. }
  91. int main()
  92. {
  93.     files;
  94.    
  95.     int n, m;
  96.     cin >> n >> m;
  97.     if (n < m)
  98.         cout << "NO";
  99.     else
  100.     {
  101.         vector<int>a(n + 1, 1);
  102.         vector <int> k;
  103.         int prom;
  104.         for (int i = 1; i <= m; i++)
  105.         {
  106.             cin >> prom;
  107.             k.push_back(prom);
  108.         }
  109.         sort(sor(k));
  110.         for (int i = 0; i < m; i++)
  111.         {
  112.             if (k[i] == 0)
  113.                 if (!a[k[i] + 1])
  114.                 {
  115.                     cout << "NO" << endl;
  116.                     return 0;
  117.                 }
  118.                 else
  119.                     a[k[i] + 1] = 0;
  120.             else
  121.                 if (k[i] == n)
  122.                     if (!a[k[i]])
  123.                     {
  124.                         cout << "NO" << endl;
  125.                         return 0;
  126.                     }
  127.                     else
  128.                         a[k[i]] = 0;
  129.                 else
  130.                     if (!a[k[i]])
  131.                         if (a[k[i] + 1])
  132.                             a[k[i] + 1] = 0;
  133.                         else
  134.                         {
  135.                             cout << "NO" << endl;
  136.                             return 0;
  137.                         }
  138.                     else
  139.                         a[k[i]] = 0;
  140.         }
  141.         cout << "YES";
  142.     }
  143.     return 0;
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement