제출 #1328512

#제출 시각아이디문제언어결과실행 시간메모리
1328512JohanRadio (COCI22_radio)C++20
10 / 110
1595 ms468 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 = 5e5 + 5 ;
const int LG = 20 ;
const int N = 1e8 ;
const int mod = 1e9 + 7 ;
const int MAXM = 1e9 + 7 ;
///////////////////////////////////////////////
///////////////////////////////////////////////
void solve() {
  int n ;
  cin >> n ;
  int m ;
  cin >> m ;
  vector<bool>a(n + 1 , 0) ;
  int cnt = 0 ;
  while(m --) {
    char ch ;
    cin >> ch ;
    if(ch == 'S') {
      int target ;
      cin >> target ;
      if(a[target] == 1) a[target] = 0 , cnt -- ;
      else a[target] = 1 , cnt ++ ; 
    }
    else{ 
      if(cnt < 2 ) {
        int l , r ;
        cin >> l >> r ;
        cout << "NE" << endl ;
        continue ;
      }
      else {
        int l , r ;
        cin >> l >> r ; 
        bool b = false ;
        for(int i = l ; i <= r ; i ++) {
          if(b == true) break ;
          if(a[i] == 1) {
            for(int j = i + 1 ; j <= r ; j ++) {
              if(a[j] == 1) {
                if(gcd(i , j) > 1) {
                  b = true ;
                  break ;
                }
              }
            }
          }
        }
        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...