Submission #572259

#TimeUsernameProblemLanguageResultExecution timeMemory
572259AsylzhanRadio (COCI22_radio)C++17
10 / 110
1582 ms340 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define sp ' '
#define ff first
#define ss second
#define vt vector
#define pb push_back

const int MOD = 998244353;
const int inf = 1e9 + 7;
const ll  INF = 9e18;
const int N   = 1e6 + 5;

/*-------------------------main-------------------------*/

bool a[N];

void solve(){
    #define test
    int n, q;
    cin >> n >> q;
    while (q--){
        char u;
        cin >> u;
        if (u == 'S'){
            int p;
            cin >> p;
            a[p] ^= 1;
        }
        else {
            int l, r;
            cin >> l >> r;
            bool ok = 0;
            for (int i = l; i <= r; i++){
                if (!a[i]) continue;
                for (int j = i + 1; j <= r; j++){
                    if (!a[j]) continue;
                    if (__gcd(i, j) > 1) ok = 1;
                }
            }
            if (ok) cout << "DA" << endl;
            else cout << "NE" << endl;
        }
    }
}

signed main() {
	//freopen("exam.in", "r", stdin);
	//freopen("exam.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	#ifdef tests
		cin >> t;
	#endif
	#ifdef test
		t = 1;
	#endif
	while (t--) {
		solve();
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...