zoukankan      html  css  js  c++  java
  • bzoj 5288: [Hnoi2018]游戏

    Description

    Solution

    乱搞能A的题,毁我青春
    记忆化一下扩展过程
    只要不是从 (1) 枚举到 (n) 去扩展都可以 (AC)
    于是 (random\_shuffle) 一下扩展顺序就过了
    复杂度应该是启发式合并的复杂度

    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e6+10;
    int n,a[N],L[N],R[N],m,Q,p[N];
    inline void solve(int x){
    	int l=x,r=x;
    	while(1){
    		if(l>1 && ((l<=a[l-1] && a[l-1]<=r) || !a[l-1])){
    			l--;
    			l=min(l,L[l]);r=max(r,R[l]);
    			continue;
    		}
    		if(r<n && ((l<=a[r] && a[r]<=r) || !a[r])){
    			r++;
    			l=min(l,L[r]);r=max(r,R[r]);
    			continue;
    		}
    		break;
    	}
    	L[x]=l;R[x]=r;
    }
    int main(){
      freopen("game.in","r",stdin);
      freopen("game.out","w",stdout);
      srand(19260859);
      int x,y;
      cin>>n>>m>>Q;
      for(int i=1;i<=m;i++)
    	  scanf("%d%d",&x,&y),a[x]=y;
      for(int i=1;i<=n;i++)L[i]=n+1;
      for(int i=1;i<=n;i++)p[i]=i;
      for(int i=1;i<=5;i++)random_shuffle(p+1,p+n+1);
      for(int i=1;i<=n;i++)solve(p[i]);
      while(Q--){
    	  scanf("%d%d",&x,&y);
    	  if(L[x]<=y && y<=R[x])puts("YES");
    	  else puts("NO");
      }
      return 0;
    }
    
    
  • 相关阅读:
    轮询算法
    随机算法
    加权随机算法
    平滑加权轮询算法
    预训练模型与Keras.applications.models权重资源地址
    多通道卷积操作解析
    Squeeze-and-Excitation Networks
    实验数据集概况
    Keras-图片预处理
    Keras常用层
  • 原文地址:https://www.cnblogs.com/Yuzao/p/8856829.html
Copyright © 2011-2022 走看看