T3000

Untitled

Sep 17th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5. using ld = long double;
  6.  
  7. int main()
  8. {
  9.     ll n;
  10.     cin >> n;
  11.     ll e;
  12.     cin >> e;
  13.     vector<ll> z1(n + 1);
  14.     vector<pair<ll, ll>> error;
  15.     vector<pair<ll, ll>> corect;
  16.     while (e-- > 0)
  17.     {
  18.  
  19.         ll a;
  20.         cin >> a;
  21.         z1.at(a) += 1;
  22.     }
  23.  
  24.     ll st = 1, en;
  25.     for (int i = 2; i < n + 1; i++)
  26.     {
  27.         if (z1.at(i) != z1.at(st))
  28.         {
  29.             if (z1.at(st) == 0)
  30.             {
  31.                 corect.push_back({st, i - 1});
  32.             }
  33.             else
  34.             {
  35.                 error.push_back({st, i - 1});
  36.             }
  37.             st = i;
  38.         }
  39.     }
  40.     if (z1.at(st) == 0)
  41.     {
  42.         corect.push_back({st, n});
  43.     }
  44.     else
  45.     {
  46.         error.push_back({st, n});
  47.     }
  48.     cout << "Errors: ";
  49.     for (int i = 0; i < error.size() - 1; i++)
  50.     {
  51.         if (error.at(i).first != error.at(i).second)
  52.         {
  53.             if (i != error.size() - 2)
  54.             {
  55.                 cout << error.at(i).first << "-" << error.at(i).second << ", ";
  56.             }
  57.             else
  58.             {
  59.                 cout << error.at(i).first << "-" << error.at(i).second << " ";
  60.             }
  61.         }
  62.         else
  63.         {
  64.             if (i != error.size() - 2)
  65.             {
  66.                 cout << error.at(i).first << ", ";
  67.             }
  68.             else
  69.             {
  70.                 cout << error.at(i).first << " ";
  71.             }
  72.         }
  73.     }
  74.     if (error.size() > 1)
  75.     {
  76.         cout << "and ";
  77.     }
  78.  
  79.     if (error.at(error.size() - 1).first != error.at(error.size() - 1).second)
  80.     {
  81.         cout << error.at(error.size() - 1).first << "-" << error.at(error.size() - 1).second << endl;
  82.     }
  83.     else
  84.     {
  85.         cout << error.at(error.size() - 1).first << endl;
  86.     }
  87.  
  88.     cout << "Correct: ";
  89.     for (int i = 0; i < corect.size() - 1; i++)
  90.     {
  91.         if (corect.at(i).first != corect.at(i).second)
  92.         {
  93.             if (i != corect.size() - 2)
  94.             {
  95.                 cout << corect.at(i).first << "-" << corect.at(i).second << ", ";
  96.             }
  97.             else
  98.             {
  99.                 cout << corect.at(i).first << "-" << corect.at(i).second << " ";
  100.             }
  101.         }
  102.         else
  103.         {
  104.             if (i != corect.size() - 2)
  105.             {
  106.                 cout << corect.at(i).first << ", ";
  107.             }
  108.             else
  109.             {
  110.                 cout << corect.at(i).first << " ";
  111.             }
  112.         }
  113.     }
  114.     if (corect.size() > 1)
  115.     {
  116.         cout << "and ";
  117.     }
  118.  
  119.     if (corect.at(corect.size() - 1).first != corect.at(corect.size() - 1).second)
  120.     {
  121.         cout << corect.at(corect.size() - 1).first << "-" << corect.at(corect.size() - 1).second << endl;
  122.     }
  123.     else
  124.     {
  125.         cout << corect.at(corect.size() - 1).first << endl;
  126.     }
  127.     return 0;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment