Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; #define INF INT_MAX #define LINF LLONG_MAX #define pb(x) push_back(x) #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using ll = long long; using pii = pair
; using vi = vector
; using vii = vector
; using vll = vector
; void init(){ #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("log.txt", "w", stderr); #else cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #endif } const int N = 200000; int currIdx = 0; int ST[N] = {0}; int ele[N]; void updateTree(int p, int v){ ST[N/2 + p] = v; p += N/2; for(int i=p; i>1; i>>=1){ ST[i >> 1] = __gcd(ST[i], ST[i^1]); } } int main(){ init(); unordered_map
mp; int q, x; cin >> q; char c; while(q--){ cin >> c >> x; switch(c){ case '+': mp[x].second++; if(mp[x].second == 1){ mp[x].first = currIdx; ele[currIdx] = x; updateTree(currIdx, x); currIdx++; } break; case '-': mp[x].second--; if(mp[x].second == 0){ updateTree(mp[x].first, 0); mp.erase(x); } break; } if(mp.size() == 0) cout << 1 << endl; else cout << ST[1] << endl; } return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)