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 s, n;
- cin >> s >> n;
- vector<ll> a(s + 1);
- ll ax;
- for (int i = 0; i < n; i++)
- {
- cin >> ax;
- a.at(ax) = 1;
- }
- vector<pair<ll, ll>> er;
- vector<pair<ll, ll>> cr;
- ax = 1;
- for (int i = 1; i <= s; i++)
- {
- if (i == s || a.at(i) != a.at(i + 1))
- {
- if (a.at(i) == 1)
- {
- er.push_back({ax, i});
- }
- else
- {
- cr.push_back({ax, i});
- }
- ax = i + 1;
- }
- }
- cout << "Errors: ";
- if (er.size() == 1)
- {
- if (er.at(0).first == er.at(0).second)
- {
- cout << er.at(0).first << endl;
- }
- else
- {
- cout << er.at(0).first << "-" << er.at(0).second << endl;
- }
- }
- else
- {
- if (er.at(0).first == er.at(0).second)
- {
- cout << er.at(0).first;
- }
- else
- {
- cout << er.at(0).first << "-" << er.at(0).second;
- }
- for (int i = 1; i < er.size() - 1; i++)
- {
- cout << ", ";
- if (er.at(i).first == er.at(i).second)
- {
- cout << er.at(i).first;
- }
- else
- {
- cout << er.at(i).first << "-" << er.at(i).second;
- }
- }
- cout << " and ";
- if (er.at(er.size() - 1).first == er.at(er.size() - 1).second)
- {
- cout << er.at(er.size() - 1).first;
- }
- else
- {
- cout << er.at(er.size() - 1).first << "-" << er.at(er.size() - 1).second;
- }
- cout << endl;
- }
- cout << "Correct: ";
- if (cr.size() == 1)
- {
- if (cr.at(0).first == cr.at(0).second)
- {
- cout << cr.at(0).first << endl;
- }
- else
- {
- cout << cr.at(0).first << "-" << cr.at(0).second << endl;
- }
- }
- else
- {
- if (cr.at(0).first == cr.at(0).second)
- {
- cout << cr.at(0).first;
- }
- else
- {
- cout << cr.at(0).first << "-" << cr.at(0).second;
- }
- for (int i = 1; i < cr.size() - 1; i++)
- {
- cout << ", ";
- if (cr.at(i).first == cr.at(i).second)
- {
- cout << cr.at(i).first;
- }
- else
- {
- cout << cr.at(i).first << "-" << cr.at(i).second;
- }
- }
- cout << " and ";
- if (cr.at(cr.size() - 1).first == cr.at(cr.size() - 1).second)
- {
- cout << cr.at(cr.size() - 1).first;
- }
- else
- {
- cout << cr.at(cr.size() - 1).first << "-" << cr.at(cr.size() - 1).second;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment