Submission #542424

# Submission time Handle Problem Language Result Execution time Memory
542424 2022-03-26T16:50:53 Z Zhora_004 Radio (COCI22_radio) C++17
30 / 110
389 ms 64076 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
//#include <bit>
//#include <ranges>
//#include <numbers>
#define itn int
#define sacnf scanf
#define sz(a) ((int)((a).size()))
// printf("%.10f\n", ans);
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e6 + 1;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> divs(n + 1);
    for (int i = 2; i <= n; i++) if (divs[i].empty()) for (int j = i; j <= n; j += i) divs[j].push_back(i);
    vector<int> on(n + 1, -1), cnt(n + 1);
    set<int> s;
    while (q--)
    {
        char smb;
        cin >> smb;
        if (smb == 'S')
        {
            int x;
            cin >> x;
            if (on[x] == -1) on[x] = 1;
            else on[x] = -1;
            for (int& k : divs[x])
            {
                bool prv = 0;
                if (cnt[k] > 1) prv = 1;
                cnt[k] += on[x];
                bool now = 0;
                if (cnt[k] > 1) now = 1;
                if (!prv && now) s.insert(k);
                else if (prv && !now) s.erase(k);
            }
        }
        else
        {
            int l, r;
            cin >> l >> r;
            if (s.empty()) cout << "NE\n";
            else cout << "DA\n";
        }
    }

    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 67 ms 6692 KB Output is correct
2 Correct 197 ms 32284 KB Output is correct
3 Correct 389 ms 64076 KB Output is correct
4 Correct 21 ms 6556 KB Output is correct
5 Correct 176 ms 32132 KB Output is correct
6 Correct 377 ms 63668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -