236152026-01-26 11:34:28horkaSzínes szobák (50 pont)cpp17Wrong answer 0/5037ms1616 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k,m; cin>>n>>k>>m;
    vector<int> v(n+1);
    for(int i=1; i<=n; i++)
        cin>>v[i];
    vector<array<int, 2>> op(m);
    for(auto &[a,b]:op) cin>>a>>b;
    int lo=0,hi=n+1;
    while(lo<hi-1)
    {
        int mid=(lo+hi)/2;
        bool kint=0;
        int pos=mid;
        for(auto &[a,b]:op)
        {
            if(v[pos]==a) pos+=b;
            if(pos>n) break;
            if(pos<1)
            {
                kint=1;
                break;
            }
        }
        if(kint) lo=mid;
        else hi=mid;
    }
    int ans=lo;
    lo=0,hi=n+1;
    while(lo<hi-1)
    {
        int mid=(lo+hi)/2;
        bool kint=0;
        int pos=mid;
        for(auto &[a,b]:op)
        {
            if(v[pos]==a) pos+=b;
            if(pos<1) break;
            if(pos>n)
            {
                kint=1;
                break;
            }
        }
        if(kint) hi=mid;
        else lo=mid;
    }
    ans+=n-lo;
    cout<<n-ans;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/02ms316 KiB
2Wrong answer0/037ms1588 KiB
3Wrong answer0/12ms316 KiB
4Wrong answer0/12ms500 KiB
5Wrong answer0/11ms436 KiB
6Wrong answer0/11ms316 KiB
7Wrong answer0/11ms316 KiB
8Wrong answer0/11ms316 KiB
9Wrong answer0/11ms316 KiB
10Wrong answer0/12ms508 KiB
11Wrong answer0/11ms316 KiB
12Wrong answer0/12ms316 KiB
13Wrong answer0/14ms316 KiB
14Wrong answer0/12ms316 KiB
15Wrong answer0/12ms316 KiB
16Wrong answer0/14ms532 KiB
17Wrong answer0/14ms316 KiB
18Wrong answer0/14ms316 KiB
19Wrong answer0/120ms1080 KiB
20Wrong answer0/135ms1596 KiB
21Wrong answer0/126ms1076 KiB
22Wrong answer0/128ms1340 KiB
23Wrong answer0/134ms1332 KiB
24Wrong answer0/135ms1612 KiB
25Wrong answer0/135ms1588 KiB
26Wrong answer0/135ms1608 KiB
27Wrong answer0/335ms1588 KiB
28Wrong answer0/334ms1588 KiB
29Wrong answer0/334ms1600 KiB
30Wrong answer0/335ms1596 KiB
31Wrong answer0/334ms1616 KiB
32Wrong answer0/335ms1588 KiB
33Wrong answer0/417ms1024 KiB
34Wrong answer0/428ms1332 KiB