fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MaxN=2e5;
  5. int N,Q,x,y,z;
  6. //pool[0] 是0號到1號空島的橋
  7. vector<int> pool(MaxN,1);
  8.  
  9. void build(int y){
  10. pool[y]=1;
  11. }
  12. void blow_up(int y){
  13. if(y>0){
  14. pool[y-1]=0;
  15. pool[y]=0;
  16. }else{
  17. pool[y]=0;
  18. }
  19. }
  20. int check(int y, int z){
  21.  
  22. while(y<z){
  23. if(pool[y]!=1){
  24. return 0;
  25. }
  26. else if(pool[y]==1)
  27. y++;
  28. }
  29.  
  30. return 1;
  31. }
  32. int main() {
  33. cin>>N>>Q;
  34. for(int q=1;q<=Q;q++){
  35. cin>>x;
  36. if(x==1){
  37. cin>>y;
  38. build(y);
  39. }else if(x==2){
  40. cin>>y;
  41. blow_up(y);
  42. }else if(x==3){
  43. cin>>y>>z;
  44. if(check(y,z)){
  45. cout<<"YES\n";
  46. }else{
  47. cout<<"NO\n";
  48. }
  49. }
  50.  
  51. }
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0s 5304KB
stdin
5 6
2 3
3 1 2
3 2 4
1 2
3 1 3
3 1 4
stdout
YES
NO
YES
NO