Submission #560219

# Submission time Handle Problem Language Result Execution time Memory
560219 2022-05-11T07:27:53 Z proma Radio (COCI22_radio) C++17
0 / 110
725 ms 21212 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];
            for (int i = 2; i * i <= x; i ++) {
                if (x % i == 0) {
                    if (p[i]) {
                        if (a[x]) {
                            cnt[i] ++;
                            if (cnt[i] == 1) used ++;
                        }
                        else {
                            cnt[i] --;
                            if (!cnt[i]) used --;
                        }
                    }
                    if (p[x/i]) {
                        if (a[x]) {
                            cnt[x/i] ++;
                            if (cnt[x/i] == 1) used ++;
                        }
                        else {
                            cnt[x/i] --;
                            if (!cnt[x/i]) 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 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 172 ms 3124 KB Output is correct
2 Correct 516 ms 11600 KB Output is correct
3 Correct 725 ms 21212 KB Output is correct
4 Incorrect 35 ms 2132 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -