0%

APCS-購物車

Code

#include <bits/stdc++.h>
using namespace std;


int main() {
    int a,b;cin >> a >> b;
    int n;cin >> n;
    int cnt=0;
    for(int i=0;i<n;i++){
        int x;
        int _a=0,_b=0;
        while(cin >> x){
            if(x==0)break;
            if(abs(x) == a || abs(x) == b){
                if(x == -a){
                    _a--;
                } else if(x == a){
                    _a++;
                } else if(x == b){
                    _b++;
                } else if(x == -b){
                    _b--;
                }
            }
        }
        if(_a > 0 && _b>0) cnt++;
    }

    cout << cnt << endl;


    return 0;
}