hdu 1075 What Are You Talking About

What Are You Talking About

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)
Total Submission(s): 8865    Accepted Submission(s): 2782


Problem Description
Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book into English. Can you help him?
 

Input
The problem has only one test case, the test case consists of two parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should be ignored, then some lines follow, each line contains two strings, the first one is a word in English, the second one is the corresponding word in Martian's language. A line with a single string "END" indicates the end of the directory part, and this string should be ignored. The book part starts with a single line contains a string "START", this string should be ignored, then an article written in Martian's language. You should translate the article into English with the dictionary. If you find the word in the dictionary you should translate it and write the new word into your translation, if you can't find the word in the dictionary you do not have to translate it, and just copy the old word to your translation. Space(' '), tab('\t'), enter('\n') and all the punctuation should not be translated. A line with a single string "END" indicates the end of the book part, and that's also the end of the input. All the words are in the lowercase, and each word will contain at most 10 characters, and each line will contain at most 3000 characters.
 

Output
In this problem, you have to output the translation of the history book.
 

Sample Input
START from fiwo hello difh mars riwosf earth fnnvk like fiiwj END START difh, i'm fiwo riwosf. i fiiwj fnnvk! END
 

Sample Output
hello, i'm from mars. i like earth!
 
 
STL中map的用法
 
AC代码:
#include <iostream>
#include <string>
#include <cmath>
#include <map>
using namespace std;

int main()
{
    string s,s1,s2,code;
    map<string,string>dic;
    cin>>s;
    while(cin>>s1)
    {
        if(s1=="END") break;
        cin>>s2;
        dic[s2]=s1;
    }
    cin>>s;
    getline(cin,s);
    while(getline(cin,s))
    {
        if(s=="END") break;
        for(int i=0;i<s.size();i++)
        {
            if(isalpha(s[i]))
            {
                code+=s[i];
            if(!isalpha(s[i+1]))
            {
                if(dic[code]!="")
                cout<<dic[code];
                else
                cout<<code;
                code.clear();
            }
            }
            else
            cout<<s[i];
        }
        cout<<endl;
    }
    return 0;

}


 

要解决被HDU WAF(Web应用防火墙)拒绝的问题并调整代码,可从以下几个方面着手: ### 网络访问规范 - **IP限制**:HDU WAF可能因IP存在异常访问行为而拒绝访问。检查IP是否被列入黑名单,若因频繁请求被临时封禁,可等待封禁时间结束或联系HDU相关技术支持人员说明情况,请求解封。 - **请求频率**:过度频繁的请求会触发WAF的防护机制。调整代码中的请求频率,添加适当的延迟。以下是Python中使用`time.sleep()`函数添加延迟的示例: ```python import time import requests for i in range(10): response = requests.get('http://acm.hdu.edu.cn') print(response.text) time.sleep(1) # 每次请求间隔1秒 ``` ### 代码合规性 - **请求头设置**:确保代码中的请求头信息符合正常浏览器的请求头格式。部分WAF会根据请求头信息判断请求是否正常。以下是Python中设置请求头的示例: ```python import requests headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} response = requests.get('http://acm.hdu.edu.cn', headers=headers) print(response.text) ``` - **请求参数**:检查代码中发送的请求参数是否包含恶意字符或异常内容。确保参数符合题目要求和网站规定。 ### 代码逻辑与题目要求 - **理解题目意思**:仔细阅读题目描述,确保代码逻辑符合题目要求。如VJ的题有很多格式要求,多打一个空格、没换行系统就会评测为presentation error,所以要在代码中严格遵循题目要求的输出格式[^2]。 - **优化算法复杂度**:若代码运行时间过长或占用资源过多,可能会被WAF视为异常请求。对代码中的算法进行优化,降低时间和空间复杂度。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值