제출 #1194726

#제출 시각아이디문제언어결과실행 시간메모리
1194726DeathIsAweInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
105 ms18388 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second #define ll long long using namespace std; int main() { int n, q; cin >> n >> q; int query, ans = 0; unordered_set<int> behind, infront; for (int i=1;i<n;i++) { infront.insert(i); } for (int i=0;i<q;i++) { cin >> query; if (query < 0) { query = -query; if (behind.find(query) != behind.end()) { behind.erase(query); infront.insert(query); } } else { if (behind.find(query) != behind.end()) { for (int j: behind) { if (j == query) continue; infront.insert(j); } behind.clear(); behind.insert(query); ans += 1; } else { infront.erase(query); behind.insert(query); } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...