zoukankan      html  css  js  c++  java
  • 小花梨的三角形(暴力上下扫三角形)

    思路:上下扫,注意一点细节处理就好了

    代码:

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<set>
    #include<vector>
    #include<map>
    #include<cmath>
    const int maxn=1e5+5;
    typedef long long ll;
    using namespace std;
    char str[205][205];
    int vis[205][205][205];
    int main()
    {
        
        int n;
        cin>>n;
        getchar();
        for(int t=0;t<n+1;t++)
        {
            scanf("%s",str[t]);
        }
        ll ans=0;
        for(int t=0;t<n;t++)
        {
            for(int j=t+1;j<n+1;j++)
            {
                for(int k=0;k<=t;k++)
                {
                char ss[3];
                ss[0]=str[t][k];
                ss[1]=str[j][k];
                ss[2]=str[j][k+j-t];
                sort(ss,ss+3);
                if(vis[ss[0]-'a'][ss[1]-'a'][ss[2]-'a']==0)
                {
                    vis[ss[0]-'a'][ss[1]-'a'][ss[2]-'a']=1;
                    ans++;    
                }
                }
            }
        }
        for(int t=n;t>=2;t--)
        {
            for(int j=1;j<=t/2;j++)
            {
            for(int k=1;k<=t-j;k++)
            {
            if(k-j>=0)
            {
            char ss[3];
            ss[0]=str[t][k];
            ss[1]=str[t-j][k];
            ss[2]=str[t-j][k-j];
            sort(ss,ss+3);
            if(vis[ss[0]-'a'][ss[1]-'a'][ss[2]-'a']==0)
            {
                    vis[ss[0]-'a'][ss[1]-'a'][ss[2]-'a']=1;
                    ans++;    
            }
            }
            }
             }
        }
        
        printf("%lld
    ",ans);
    
       return 0;
    }
  • 相关阅读:
    Ubuntu
    VSCode
    VSCode
    Astyle
    Qt
    待办
    Qt
    Qt
    Qt
    python pip常用命令、配置pip源
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10887039.html
Copyright © 2011-2022 走看看