제출 #1297544

#제출 시각아이디문제언어결과실행 시간메모리
1297544rana_azkaInfinite Race (EGOI24_infiniterace2)C++20
51 / 100
1095 ms636 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5;

int n, m;
bool stat[MAXN+5];

void mulaidarinol(){}

void solve(){
    cin >> n;
    n--;
    for(int i = 1; i <= n; i++) stat[i] = 1;
    
    int ans = 0;
    cin >> m;
    while(m--){
        int evnt; cin >> evnt;
        if(evnt > 0){
            if(stat[evnt] == 0){
                ans++;
                for(int i = 1; i <= n; i++){
                    if(i == evnt) continue;
                    stat[i] = 1;
                }
            }else{
                stat[evnt] = 0;
            }
        }else{
            evnt = -evnt;
            if(stat[evnt] == 0){
                stat[evnt] = 1;
            }
        }
        
        // cerr << endl;
        // cerr << evnt << " : ";
        // for(int i = 1; i <= n; i++) cerr << stat[i] << ' ';
    }

    cerr << "=> ";
    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int tc = 1;
    // cin >> tc;
    while(tc--){
        // mulaidarinol();
        solve();
    }

    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...