제출 #1328551

#제출 시각아이디문제언어결과실행 시간메모리
1328551husuuuRadio (COCI22_radio)C++20
0 / 110
63 ms16204 KiB
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////////
#define int long long
#define endl "\n"
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3F3F3F3F3F3F3F3F
#define ss second
#define ff first
#define pb push_back
#define ins insert
#define all(a) a.begin() , a.end()
#define input(a , n) for(int i = 0 ; i < n ; i ++) cin >> a[i]
///////////////////////////////////////////////
const int sz = 1e6 + 5 ;
const int LG = 20 ;
const int N = 1e8 ;
const int mod = 1e9 + 7 ;
const int MAXM = 1e9 + 7 ;
///////////////////////////////////////////////
int bankai[sz] ;
vector<int>spf(sz , INF) ;
void f() {
  for(int i = 2 ; i < sz ; i ++) {
    for(int j = i ; j < sz ; j += i) {
      spf[j] = min(spf[j], i);
    } 
  }
}
void get(int n , vector<int>&a) {
  while(n > 1) {
    if(spf[n] > 1)a.pb(spf[n]) ;
    n /= spf[n] ;
  }
}
///////////////////////////////////////////////
void solve() {
  f() ;
  int n ;
  cin >> n ;
  int m ;
  cin >> m ;
  int cnt = 0 ;
  vector<bool>a(n + 1 , 0) ;
  while(m --) {
    char ch ;
    cin >> ch ;
    if(ch == 'S') {
      int target ;
      cin >> target ;
      if(a[target] == 0) {
        vector<int>divs ;
        //cout << "0000000" << endl ;
        get(target , divs) ;
        for(int i : divs) {
          //cout << i << ' ' ;
          bankai[i] ++ ;
          if(bankai[i] > 1) {
            cnt ++ ;
          }
        }
        a[target] = 1 ;
        //cout << endl ;
      }
      else {
        vector<int>divs ;
        //cout << "1111111" << endl ;
        get(target , divs) ;
        for(int i : divs) {
          //cout << i << ' ' ; 
          if(bankai[i] > 1) bankai[i] -- ;
          if(bankai[i] <= 1) {
            cnt -- ;
          }
        }
        a[target] = 0 ;
        //cout << endl ;
      }
    }
    else{ 
        int l , r ;
        cin >> l >> r ; 
        bool b = false ;
        //cout << cnt << ' '  ;
        if(cnt > 0) b = true ;
        if(b == true) {
          cout << "DA" << endl ;
          continue ; 
        }
        else {
          cout << "NE" << endl ;
          continue ;
      }
    }
  }
}
///////////////////////////////////////////////
///////////////////////////////////////////////
signed main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  IO ;
  int t = 1 ; // cin >> t ;  
  while(t --) {
    solve() ;
    cout << endl ;
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...