zoukankan      html  css  js  c++  java
  • 2017 计蒜之道 初赛 第五场 B. UCloud 的安全秘钥(简单)

    暴力。

    暴力枚举$S$串的每一个长度为$m$的子串,排序判断即可。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <map>
    #include <set>
    #include <cmath>
    using namespace std;
    
    int n,m;
    
    int s[100100];
    int t[100100];
    
    int p[100100];
    
    map<int,int>m1,m2;
    
    int main()
    {
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
    
    	
    	int Q;
    	scanf("%d",&Q);
    	while(Q--)
    	{
    		scanf("%d",&m);
    		for(int i=1;i<=m;i++) scanf("%d",&t[i]);
    		sort(t+1,t+1+m);
    		if(m>n)
    		{
    			printf("0
    ");
    			continue;
    		}
    
    		int ans = 0;
    
    		for(int i=1;i<=n;i++)
    		{
    			int sz = 0;
    			for(int j=i;j<=i+m-1;j++) sz++, p[sz] = s[j];
    			sort(p+1,p+1+m);
    
    			bool suc = 1;
    			for(int j=1;j<=m;j++)
    			{
    				if(p[j] == t[j]) continue;
    				suc = 0;
    			}
    
    			ans = ans + suc;
    		}
    
    		printf("%d
    ",ans);
    	}
    
    
    	return 0;
    }
  • 相关阅读:
    Win7 安装
    线上java排查
    spring boot
    redisson
    Jcaptca 图片
    URL重写
    gradle导出依赖的jar包
    Redis tomcat
    flex 通过htmlservices链接moss的rest(rest 的get post方式)
    java语言MySQL批处理
  • 原文地址:https://www.cnblogs.com/zufezzt/p/6938397.html
Copyright © 2011-2022 走看看