Submission #560228

# Submission time Handle Problem Language Result Execution time Memory
560228 2022-05-11T07:39:52 Z proma Radio (COCI22_radio) C++17
30 / 110
782 ms 25104 KB
#include <bits/stdc++.h>

#define int long long
#define see(x) cout<<#x<<"="<<x<<"\n";
#define endl "\n"

using namespace std;

const int N = 1e6+5;
const int INF = 1e18;

int n, q, p[N], a[N], cnt[N], used;
vector <int> prime;

void primes() {
    for (int i = 2; i <= n; i ++) p[i] = 1;
    for (int i = 2; i <= n; i ++) {
        if (p[i]) {
            for (int j = 2 * i; j <= n; j += i) {
                p[j] = 0;
            }
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
/*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/

    cin >> n >> q;

    primes();

    while (q --) {
        char c;
        cin >> c;
        if (c == 'S') {
            int x;
            cin >> x;
            a[x] = 1 - a[x];
            if (p[x]) {
                if (a[x]) {
                    cnt[x] ++;
                    if (cnt[x] == 2) used ++;
                }
                else {
                    cnt[x] --;
                    if (cnt[x] == 1) used --;
                }
            }
            for (int i = 2; i * i <= x; i ++) {
                if (x % i == 0) {
                    if (p[i]) {
                        if (a[x]) {
                            cnt[i] ++;
                            if (cnt[i] == 2) used ++;
                        }
                        else {
                            cnt[i] --;
                            if (cnt[i] == 1) used --;
                        }
                    }
                    if (p[x/i]) {
                        if (a[x]) {
                            cnt[x/i] ++;
                            if (cnt[x/i] == 2) used ++;
                        }
                        else {
                            cnt[x/i] --;
                            if (cnt[x/i] == 1) used --;
                        }
                    }
                }
            }
        }
        else {
            int l, r;
            cin >> l >> r;
            if (used) cout << "DA\n";
            else cout << "NE\n";
        }
    }


    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 191 ms 2900 KB Output is correct
2 Correct 476 ms 12428 KB Output is correct
3 Correct 765 ms 24016 KB Output is correct
4 Correct 32 ms 2728 KB Output is correct
5 Correct 306 ms 12828 KB Output is correct
6 Correct 782 ms 25104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -