9361 | 2024-02-21 09:36:33 | szil | Színes szobák (50 pont) | csharp | Compilation error |
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAXN = 100'002;
int c[MAXN], n, k, m;
vector<pair<int, int>> v;
bool f(int pos, int border) {
for (auto [a, b] : v) {
if (c[pos] == a) pos += b;
if (pos <= border && border == 0) return true;
if (pos >= border && border == n+1) return true;
}
return false;
}
void solve() {
cin >> n >> k >> m;
v.resize(m);
for (int i = 1; i <= n; i++) cin >> c[i];
for (auto &[a, b] : v) {
cin >> a >> b;
}
int ans = 0;
{
int lo = 0, hi = n;
while (lo < hi) {
int mid = (lo + hi + 1) / 2;
if (f(mid, 0)) lo = mid;
else hi = mid - 1;
}
ans += lo;
}
{
int lo = 0, hi = n+1;
while (lo < hi) {
int mid = (lo + hi) / 2;
if (f(mid, n+1)) hi = mid;
else lo = mid + 1;
}
ans += n-lo+1;
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
exit status 1
Compilation failed: 7 error(s), 0 warnings