This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
#include <numeric>
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppi pair<int,pair<int,int>>
#define int int64_t
using namespace std;
// /\_/\
// (= ._.)
// / > \>
// encouraging cat
const int INF = 10000000000000000;
//const int mod = 1000000007;
const int mod = 998244353;
const int MAXN = 200005;
//ifstream fin('xor.in');
//ofstream fout('xor.out');
signed main()
{
int n,q;
cin >> n >> q;
int laped = 0;
vector<pair<bool, int>> infront(n, {true, 0}); // i infront of A
int res = 0;
while (q--)
{
int x;
cin >> x;
if (x > 0)
{
if (!infront[x].first && infront[x].second == laped)
{
laped++;
res++;
infront[x].second = laped;
}
else
{
infront[x].first = false;
infront[x].second = laped;
}
}
else
{
infront[-x].first = true;
}
}
cout << res << '\n';
return 0;
}
Compilation message (stderr)
Main.cpp:32:1: warning: multi-line comment [-Wcomment]
32 | // /\_/\
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |