#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;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, q;
cin >> n >> q;
vector<vector<int>> divs(n + 1);
for (int i = 2; i <= n; i++) if (divs[i].empty()) for (int j = i; j <= n; j += i) divs[j].push_back(i);
vector<int> on(n + 1, -1), cnt(n + 1);
set<int> s;
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])
{
bool prv = 0;
if (cnt[k] > 1) prv = 1;
cnt[k] += on[x];
bool now = 0;
if (cnt[k] > 1) now = 1;
if (!prv && now) s.insert(k);
else if (prv && !now) s.erase(k);
}
}
else
{
int l, r;
cin >> l >> r;
if (s.empty()) cout << "NE\n";
else cout << "DA\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
67 ms |
6692 KB |
Output is correct |
2 |
Correct |
197 ms |
32284 KB |
Output is correct |
3 |
Correct |
389 ms |
64076 KB |
Output is correct |
4 |
Correct |
21 ms |
6556 KB |
Output is correct |
5 |
Correct |
176 ms |
32132 KB |
Output is correct |
6 |
Correct |
377 ms |
63668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |