제출 #1342309

#제출 시각아이디문제언어결과실행 시간메모리
1342309mantaggezInfinite Race (EGOI24_infiniterace2)C++20
34 / 100
13 ms1732 KiB
#include <bits/stdc++.h>

using namespace std;

const int nx = 2e5+5;

int n, q, ans;  
bool b[nx];
vector<int> v;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> q;
    while(q--) {
        int x; cin >> x;
        int idx = abs(x);
        bool lap = false;

        if(x > 0) {
            if(b[idx]) lap = true;
        }
        else {
            if(!b[idx]) lap = true;
        }

        if(lap) {
            ans++;
            for(int p : v) b[p] = false;
            v.clear();
        }

        if(x > 0) {
            if(!b[idx]) {
                b[idx] = true;  
                v.push_back(idx);
            }
            else {
                if(b[idx]) {
                    b[idx] = false;
                }
            }
        }
    }

    cout << ans << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...