【模拟】2011 Asia ChenDu Regional Contest 成都现场赛 hdu 4119

本文深入探讨了使用C++解决复杂字符串问题的策略,通过旋转矩阵和自定义函数实现高效字符串匹配与操作。文章详细介绍了算法实现步骤、关键细节处理以及优化技巧,旨在为读者提供解决类似技术难题的实用指南。

模拟,注意细节就可以了。

#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <time.h>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <cstdlib>
#include <limits.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

#define LL long long
#define MIN INT_MIN
#define MAX INT_MAX
#define PI acos(-1.0)
#define FRE freopen("input.txt","r",stdin)
#define FF freopen("output.txt","w",stdout)
#define N 55
char g[N][N];
char mask[N][N];
char str[25];
set<string> se,ans;
int n,m;
string message[4];
int d[4][4] = {
    0,1,2,3,
    1,2,3,0,
    2,3,0,1,
    3,0,1,2};
void rotate () {
    int i,j;
    char tmp[N][N];
    for (i = 0;i < n; i++) {
        for (j = 0; j < n; j++) {
            tmp[i][j] = mask[i][j];
        }
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            mask[j][n-i-1] = tmp[i][j];
        }
    }
}
string getstring () {
    int i,j;
    string s;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (mask[i][j] == '*') {
                s += g[i][j];
            }
        }
    }
    return s;
}
string get(string s) {
    string ret;
    bool ok = 0;
    bool ookk = 0;
    int i;
    for (i = 0; i < s.length(); i++) {
        if (s[i] == '.') {
            ok = 1;
        }else {
            if (ok) {
                ok = 0;
                if (ookk)
                ret += ' ';
            }
            ret += s[i];
            ookk = 1;
        }
    }
    return ret;
}
bool chk(string s) {
    int i,j;
    string tmp;
    for (i = 0; i < s.length(); i++) {
        if (s[i] == ' ') {
            if (se.find(tmp) == se.end())return false;
            tmp.clear();
        }
        else
        tmp += s[i];
    }
    if (se.find(tmp) == se.end())return false;
    return true;
}

void gao () {
    int i,j;
    //得出4种情况的字符串
    for (i = 0; i < 4; i++) {
        message[i] = getstring();
        rotate();
    }
    string s;
    for (i = 0; i < 4; i++) {
        s.clear();
        for (j = 0; j < 4; j++) { //以特定的顺序排成新的字符串
            s += message[d[i][j]];
        }
        s = get(s);
        if (chk(s)) ans.insert(s);
    }
    if (ans.size() == 0) puts("FAIL TO DECRYPT");
    else cout<<*ans.begin()<<endl;
}
int main () {
    int t;
    scanf("%d",&t);
    int ca = 1;
    while (t--) {
        se.clear();
        ans.clear();
        scanf("%d",&n);
        int i,j,k;
        for (i = 0; i < n; i++) scanf("%s",g[i]);
        for (i = 0; i < n; i++) scanf("%s",mask[i]);
        scanf("%d",&m);
        for (i = 0; i < m; i++) {
            scanf("%s",str);
            se.insert(str);
        }
        printf("Case #%d: ",ca++);
        gao();
    }
    return 0;
}


Maven 依赖库路径的配置通常涉及本地仓库的设置和远程仓库的定义。若本地仓库路径被设置为 `C:\2025chendu\maven_repository`,但出现依赖解析问题,可能与路径权限、配置错误或依赖本身的状态有关。 ### 配置 Maven 本地仓库路径 Maven 默认使用用户目录下的 `.m2/repository` 作为本地仓库路径。若需要更改该路径,可以在 `settings.xml` 文件中配置 `<localRepository>` 属性: ```xml <settings> <localRepository>C:\2025chendu\maven_repository</localRepository> </settings> ``` 此配置确保 Maven 使用指定路径作为本地依赖存储目录。若路径不存在,Maven 会在构建过程中自动创建该目录[^2]。 ### 解决本地仓库路径相关问题 若 Maven 项目提示依赖路径错误或依赖无法找到,可以尝试以下方法: 1. **清理本地仓库缓存** 有时本地仓库中的依赖文件可能损坏或不完整,导致依赖解析失败。可手动删除本地仓库中相关依赖目录,强制 Maven 重新下载依赖: ```bash rm -rf C:\2025chendu\maven_repository\com\aliyun ``` 然后执行 `mvn clean install` 重新下载依赖[^2]。 2. **检查依赖仓库配置** 若依赖不在 Maven Central,需要在 `pom.xml` 或 `settings.xml` 中配置正确的远程仓库地址。例如阿里云 SDK 可能需要添加阿里云的仓库: ```xml <repositories> <repository> <id>aliyun</id> <url>https://maven.aliyun.com/repository/public</url> </repository> </repositories> ``` 3. **手动安装依赖** 若依赖无法通过远程仓库获取,可以手动下载依赖的 jar 包,并使用 `mvn install:install-file` 命令安装到本地仓库: ```bash mvn install:install-file -Dfile=aliyun-java-sdk-core-4.3.4.jar -DgroupId=com.aliyun -DartifactId=aliyun-java-sdk-core -Dversion=4.3.4 -Dpackaging=jar ``` 安装完成后,即可在 `pom.xml` 中引用该依赖[^2]。 4. **检查权限和路径问题** 若本地仓库路径包含特殊字符或空格,可能导致 Maven 无法正确访问。确保路径为标准格式,并具有读写权限。此外,若使用代理或内网环境,需在 `settings.xml` 中正确配置代理信息: ```xml <proxies> <proxy> <id>example-proxy</id> <active>true</active> <protocol>http</protocol> <host>proxy.example.com</host> <port>8080</port> <username>user</username> <password>pass</password> <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> </proxy> </proxies> ``` ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值