2451 | 2023-01-13 10:28:17 | TuruTamas | Tom és Jerry 3 | cpp11 | Compilation error |
#include <bits/stdc++.h>
using namespace std;
long N, M;
long main() {
ios::sync_with_stdio(0); cin.tie();
cin >> N >> M;
vector<long> S(N);
for (size_t i = 0; i < N; i++)
{
cin >> S[i];
}
long a, b;
vector<pair<bool, pair<long, long>>> A(M);
{
vector<vector<long>> B(N);
for (size_t i = 0; i < M; i++)
{
cin >> a >> b;
a--; b--;
for (size_t k = a; k < b + 1; k++)
{
B[k].push_back(i);
}
A[i].second = {a, b};
}
for (size_t i = 0; i < N; i++)
{
if (B[i].size() > 1) {
for (size_t k = 0; k < B[i].size(); k++)
{
A[B[i][k]].first = true;
}
}
}
}
bool f = true;
for (pair<bool, pair<long, long>> i : A)
{
sort(S.begin() + i.second.first, S.begin() + i.second.second + 1);
}
while (f) {
f = false;
for (pair<bool, pair<long, long>> i : A)
{
if (i.first && !is_sorted(S.begin() + i.second.first, S.begin() + i.second.second + 1)) {
sort(S.begin() + i.second.first, S.begin() + i.second.second + 1);
f = true;
}
}
}
long counter = 0;
for (size_t i = 0; i < S.size(); i++)
{
if (S[i] == i + 1) counter++;
}
cout << counter;
}
exit status 1
cc1plus: error: '::main' must return 'int'
Exited with error status 1