답안 #542420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
542420 2022-03-26T16:35:31 Z Zhora_004 Radio (COCI22_radio) C++17
30 / 110
478 ms 68064 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;

void modify(vector<int>& segtree, int& id, int& v, int u, int tl, int tr)
{
    if (tl == tr) segtree[u] += v;
    else
    {
        int tm = (tl + tr) >> 1;
        if (id <= tm) modify(segtree, id, v, u * 2 + 1, tl, tm);
        else modify(segtree, id, v, u * 2 + 2, tm + 1, tr);
        segtree[u] = max(segtree[u * 2 + 1], segtree[u * 2 + 2]);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<vector<int>> divs(N);
    for (int i = 2; i < N; i++) if (divs[i].empty()) for (int j = i; j < N; j += i) divs[j].push_back(i);
    int n, q;
    cin >> n >> q;
    vector<int> on(N, -1);
    int len = 1;
    while (len <= n) len <<= 1;
    vector<int> segtree(len << 1);
    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]) modify(segtree, k, on[x], 0, 0, len - 1);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            if (segtree[0] > 1) cout << "DA\n";
            else cout << "NE\n";
        }
    }

    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 358 ms 59816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 60880 KB Output is correct
2 Correct 478 ms 63872 KB Output is correct
3 Correct 471 ms 68064 KB Output is correct
4 Correct 359 ms 60740 KB Output is correct
5 Correct 368 ms 63712 KB Output is correct
6 Correct 422 ms 67860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 358 ms 59816 KB Output isn't correct
2 Halted 0 ms 0 KB -