每日一题 2019/4/6

今天是cf让我有点难过就差几分钟但还是要写题的一天。

今天时间不多了,搞个稍微简单点的,就把天梯赛那个模拟补了吧。

搞了半天也只有18分。。

upd:好了,结论就是,以后无论如何,在?.size()前面加个int强转

#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<ext/rope>
#include<iostream>
#include<algorithm>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) x & (-x)
#define PII  pair<int, int> 
#define all(x) x.iin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
using __gnu_cxx::crope;

string s;

int main()
{
	int t; cin >> t;
	cin.get();
	while(t--){
		getline(cin, s);
		cout << s << endl;

		while(s[0] == ' ') s.erase(s.begin());
		while(s[(int)s.size()-1] == ' ') s.erase(s.end() - 1);
		rep(i, 0, (int)s.size() - 1){
			if(s[i] == ' '){
				while(s[i+1] == ' ') s.erase(s.begin() + i + 1);
				if(s[i+1] < '0' || (s[i+1] > '9' && s[i+1] < 'A') || (s[i+1] > 'Z' && s[i+1] < 'a') || s[i+1] > 'z') s.erase(s.begin() + i);
			}
		}

		rep(i, 0, (int)s.size() - 1){
			if(s[i] >= 'A' && s[i] <= 'Z' && s[i] != 'I') s[i] -= 'A' - 'a';
		}

		for(int i = 0; ; i++){
			i = s.find("can you", i);
			if(i == -1) break;
			if((i == 0 || s[i-1] < '0' || (s[i-1] > '9' && s[i-1] < 'A') || (s[i-1] > 'Z' && s[i-1] < 'a') || s[i-1] > 'z')
					&& (i == (int)s.size() - 7 || s[i+7] < '0' || (s[i+7] > '9' && s[i+7] < 'A') || (s[i+7] > 'Z' && s[i+7] < 'a') || s[i+7] > 'z')){
				s.replace(i, 7, "A can");
			}
		}

		for(int i = 0; ; i++){
			i = s.find("could you", i);
			if(i == -1) break;
			if((i == 0 || s[i-1] < '0' || (s[i-1] > '9' && s[i-1] < 'A') || (s[i-1] > 'Z' && s[i-1] < 'a') || s[i-1] > 'z') 
					&& (i == (int)s.size() - 9 || s[i+9] < '0' || (s[i+9] > '9' && s[i+9] < 'A') || (s[i+9] > 'Z' && s[i+9] < 'a') || s[i+9] > 'z')){
				s.replace(i, 9, "A could");
			}
		}

		for(int i = 0; ; i++){
			i = s.find("I", i);
			if(i == -1) break;
			if((i == 0 || s[i-1] < '0' || (s[i-1] > '9' && s[i-1] < 'A') || (s[i-1] > 'Z' && s[i-1] < 'a') || s[i-1] > 'z')
					&& (i == (int)s.size() - 1 || s[i+1] < '0' || (s[i+1] > '9' && s[i+1] < 'A') || (s[i+1] > 'Z' && s[i+1] < 'a') || s[i+1] > 'z')){
				s.replace(i, 1, "you");
			}
		}

		for(int i = 0; ; i++){
			i = s.find("me", i);
			if(i == -1) break;
			if((i == 0 || s[i-1] < '0' || s[i-1] > '9' && s[i-1] < 'A' || s[i-1] > 'Z' && s[i-1] < 'a' || s[i-1] > 'z')
					&& (i == (int)s.size() - 2 || s[i+2] < '0' || (s[i+2] > '9' && s[i+2] < 'A') || (s[i+2] > 'Z' && s[i+2] < 'a') || s[i+2] > 'z')){
				s.replace(i, 2, "you");
			}
		}

		rep(i, 0, (int)s.size() - 1){
			if(s[i] == '?') s[i] = '!';
			else if(s[i] == 'A') s[i] = 'I';
		}
		cout << "AI: " << s << endl;
	}
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值