zoukankan      html  css  js  c++  java
  • 百练4092:牛仔裤

    传送门:http://bailian.openjudge.cn/practice/4092

    【题解】

    这啥玩意儿啊写个暴力就没了

    怎么一直wa啊。。。

    注意要把ans清空啊。。。wori

    # include <stdio.h>
    # include <string.h>
    # include <iostream>
    # include <algorithm>
    // # include <bits/stdc++.h>
    
    using namespace std;
    
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    const int M = 5e5 + 10;
    const int mod = 1e9+7;
    
    # define RG register
    # define ST static
    
    int n;
    char s[11][66];
    
    char ans[66], t[66];
    
    inline bool ok(char *t, char *s, int l) {
        for (int i=0; i<l; ++i)
            if(t[i] < s[i]) return 1;
            else if(t[i] > s[i]) return 0;
        return 0;
    }
    
    int main() {
        int T; cin >> T;
        while(T--) {
            bool have = 0;
            cin >> n;
            for (int i=1; i<=n; ++i) scanf("%s", s[i]+1);
            for (int len=60; len>=3; --len) {
                bool oo = 0;
                for (int j=1; j<=61-len; ++j) {
                    bool gg2 = 0;
                    for (int nx=2; nx<=n; ++nx) {
                        bool suc = 0;
                        for (int nb=1; nb<=61-len; ++nb) {
                            bool gg = 0;
                            for (int o=0; o<len; ++o)
                                if(s[1][j+o] != s[nx][nb+o]) {
                                    gg = 1;
                                    break;
                                }
                            if(!gg) {
                                suc = 1;
                                break;
                            }
                        }
                        if(!suc) {
                            gg2 = 1;
                            break;
                        }
                    }
                    if(gg2) continue;
                    for (int k=0; k<len; ++k) t[k] = s[1][j+k]; t[len] = 0;
                    if(!oo || ok(t, ans, len)) {
                        for (int k=0; k<len; ++k) ans[k] = t[k];
                        ans[len] = 0;
                        oo = 1;
                    }
                }
                if(!oo) continue;
                have = 1;
                printf("%s
    ", ans);
                break;
            }
            if(!have) puts("no significant commonalities");
        }
        return 0;
    }
    View Code
  • 相关阅读:
    微信小程序入门实例
    textarea 的value值以及演示
    Think php (TP5) 批量删除全部源码
    Think php TP5 CURD 增删改查全部源码
    TP5 Think php 批量添加全部源码
    centos7 supervisor管理redis
    Centos7 设置redis开机自启
    Centos7安装gearman和php扩展
    nginx-403
    FFmpeg-截取视频图片
  • 原文地址:https://www.cnblogs.com/galaxies/p/bailian4092.html
Copyright © 2011-2022 走看看