Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- int main()
- {
- ll n;
- cin >> n;
- ll e;
- cin >> e;
- vector<ll> z1(n + 1);
- vector<pair<ll, ll>> error;
- vector<pair<ll, ll>> corect;
- while (e-- > 0)
- {
- ll a;
- cin >> a;
- z1.at(a) += 1;
- }
- ll st = 1, en;
- for (int i = 2; i < n + 1; i++)
- {
- if (z1.at(i) != z1.at(st))
- {
- if (z1.at(st) == 0)
- {
- corect.push_back({st, i - 1});
- }
- else
- {
- error.push_back({st, i - 1});
- }
- st = i;
- }
- }
- if (z1.at(st) == 0)
- {
- corect.push_back({st, n});
- }
- else
- {
- error.push_back({st, n});
- }
- cout << "Errors: ";
- for (int i = 0; i < error.size() - 1; i++)
- {
- if (error.at(i).first != error.at(i).second)
- {
- if (i != error.size() - 2)
- {
- cout << error.at(i).first << "-" << error.at(i).second << ", ";
- }
- else
- {
- cout << error.at(i).first << "-" << error.at(i).second << " ";
- }
- }
- else
- {
- if (i != error.size() - 2)
- {
- cout << error.at(i).first << ", ";
- }
- else
- {
- cout << error.at(i).first << " ";
- }
- }
- }
- if (error.size() > 1)
- {
- cout << "and ";
- }
- if (error.at(error.size() - 1).first != error.at(error.size() - 1).second)
- {
- cout << error.at(error.size() - 1).first << "-" << error.at(error.size() - 1).second << endl;
- }
- else
- {
- cout << error.at(error.size() - 1).first << endl;
- }
- cout << "Correct: ";
- for (int i = 0; i < corect.size() - 1; i++)
- {
- if (corect.at(i).first != corect.at(i).second)
- {
- if (i != corect.size() - 2)
- {
- cout << corect.at(i).first << "-" << corect.at(i).second << ", ";
- }
- else
- {
- cout << corect.at(i).first << "-" << corect.at(i).second << " ";
- }
- }
- else
- {
- if (i != corect.size() - 2)
- {
- cout << corect.at(i).first << ", ";
- }
- else
- {
- cout << corect.at(i).first << " ";
- }
- }
- }
- if (corect.size() > 1)
- {
- cout << "and ";
- }
- if (corect.at(corect.size() - 1).first != corect.at(corect.size() - 1).second)
- {
- cout << corect.at(corect.size() - 1).first << "-" << corect.at(corect.size() - 1).second << endl;
- }
- else
- {
- cout << corect.at(corect.size() - 1).first << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment