#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t,s;
cin >> t >> s;
bool ck[t+1],ckgcd=0;
memset(ck,0,sizeof(ck));
while(s--)
{
int n;
char s;
cin >> s;
if(s == 'S')
{
cin >> n;
if(ck[n]==1)
{
ck[n]=0;
}
else
{
ck[n]=1;
}
}
else
{
int l,r;
cin >> l >> r;
ckgcd=0;
for(int i=l;i<=r;i++)
{
for(int j=i+1;j<=r;j++)
{
if(ck[i]==1 && ck[j]==1 && __gcd(i,j)>1)
{
ckgcd=1;
break;
}
}
if(ckgcd==1)
{
break;
}
}
if(ckgcd==1)
{
cout << "DA" << endl;
}
else
{
cout << "NE" << endl;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1580 ms |
1032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Execution timed out |
1580 ms |
1032 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |