Submission #1080265

#TimeUsernameProblemLanguageResultExecution timeMemory
1080265wiwihoInfinite Race (EGOI24_infiniterace2)C++14
100 / 100
24 ms2904 KiB
#include <bits/stdc++.h> using namespace std; #define iter(v) v.begin(), v.end() #define pb emplace_back #define ff first #define ss second using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #ifdef zisk void debug() { cerr << "\n"; } template<class T, class ... U> void debug(T a, U... b) { cerr << a << " ", debug(b...); } template<class T> void pary(T l, T r){ while (l != r) cerr << *l << " ", l++; cerr << "\n"; } #else #define debug(...) void() #define pary(...) void() #endif int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> r(n + 1); vector<bool> back(n + 1); int cur = 0; auto is_back = [&](int x) { return r[x] == cur && back[x]; }; int q; cin >> q; while (q--) { int x; cin >> x; if (x > 0) { if (is_back(x)) cur++; r[x] = cur; back[x] = true; } else { back[-x] = false; } } cout << cur << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...