답안 #692653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
692653 2023-02-02T03:37:10 Z Killer2501 Radio (COCI22_radio) C++17
0 / 110
190 ms 25316 KB
#include<bits/stdc++.h>

using namespace std;
const int N = 2e5+5;
struct IT
{
    int n;
    vector<int> st;
    IT(int _n)
    {
        n = _n;
        st.resize(n*4+1, 0);
    }
    void build(int id, int l, int r, int pos, int x)
    {
        if(l == r)
        {
            st[id] = x;
            return;
        }
        int mid = (l+r)>>1;
        if(pos <= mid)build(id<<1, l, mid, pos, x);
        else build(id<<1|1, mid+1, r, pos, x);
        st[id] = max(st[id<<1], st[id<<1|1]);
    }
    void build(int pos, int x)
    {
        build(1, 1, n, pos, x);
    }
    int get(int id, int l, int r, int u, int v)
    {
        if(u <= l && r <= v)return st[id];
        if(u > r || l > v)return 0;
        int mid = (l+r)>>1;
        return max(get(id<<1, l, mid, u, v), get(id<<1|1, mid+1, r, u, v));
    }
    int get(int l, int r)
    {
        return get(1, 1, n, l, r);
    }
};

int main()
{
    #define task "test"
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a, on;
    a.resize(n+1, 0);
    on.resize(n+1, 0);
    for(int i = 2; i <= n; i ++)
    {
        //cout << a[i] <<" ";
        for(int j = 2; j <= n/i; j ++)
            a[i*j] = max(a[i*j], (j-1)*i);
    }
    IT it(n);
    while(m -- > 0)
    {
        char c;
        cin >> c;
        if(c == 'S')
        {
            int pos;
            cin >> pos;
            on[pos] ^= 1;
            if(on[pos])
            {
                it.build(pos, a[pos]);
            }
            else
            {
                it.build(pos, 0);
            }
        }
        else
        {
            int l, r;
            cin >> l >> r;
            if(it.get(l, r) >= l)cout << "DA\n";
            else cout << "NE\n";
        }
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 3632 KB Output is correct
2 Correct 128 ms 13456 KB Output is correct
3 Correct 190 ms 25316 KB Output is correct
4 Incorrect 16 ms 2772 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -