Submission #555103

#TimeUsernameProblemLanguageResultExecution timeMemory
555103fuad27Radio (COCI22_radio)C++17
0 / 110
219 ms2072 KiB
#include<bits/stdc++.h> using namespace std; template<typename T> auto operator<<(ostream &os, T&v)->decltype(v.begin(), os){ os << "["; int f = 0; for(auto i:v) { if(f++)os << ", "; os << i; } os << "]"; return os; } template<typename F, typename S> ostream& operator<<(ostream &os, pair<F, S> const &p) { return os << "(" << p.first << ", " << p.second << ")"; } ostream& operator<<(ostream &os, string& s) { for(char i:s){ os << i; } return os; } void debug(){} template<typename T, typename... V> void debug(T t, V... v) { cerr << t; if(sizeof...(v)) { cerr << ", "; debug(v...); } } #ifdef LOCAL #define dbg(x...) cerr << "[" << #x << "]: " << "["; debug(x); cerr << "]\n"; #else #define dbg(x...) #endif int main () { int n, q; cin >> n >> q; if(0) { // if(n <= 100 and q <= 200) { vector<int> v(n+1); while(q--) { char c; cin >> c; if(c == 'S') { long long in; cin >> in; v[in] ^= 1; } else if(c == 'C') { long long l, r; cin >> l >> r; bool check = false; for(int i =l;i<=r;i++) { for(int j = l;j<=r;j++) { if(j == i)continue; if(!v[j] or !v[i])continue; if(__gcd(i, j)!=1) { check = true; } } } cout << (check?"DA":"NE") << "\n"; } } } else { vector<bool> used(n+1); vector<long long> cnt(n+1); long long c = 0; while(q--) { char ch; cin >> ch; if(ch == 'S') { long long in; cin >> in; if(!used[in]) { used[in] = true; cnt[in]++; if(cnt[in] == 2)c++; for(int i = 2;i*i<=in;i++) { if(in%i == 0) { cnt[i]++; if(cnt[i] == 2)c++; if(in/i!=i) { cnt[in/i]++; if(cnt[in/i] == 2)c++; } } } } else { used[in] = false; cnt[in]--; if(cnt[in] == 1)c--; for(int i = 2;i*i<=in;i++) { if(in%i == 0) { cnt[i]--; if(cnt[i] == 1)c--; if(in/i!=i) { cnt[in/i]--; if(cnt[in/i] == 1)c--; } } } } dbg(cnt); } else { long long l, r; cin >> l >> r; cout << c << "\n"; cout << (c?"DA":"NE") << "\n"; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...