# 天梯赛练习2 补题

## L1-064

``````#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin >> t;
getchar();
while(t --) {
string s;
getline(cin, s);
cout << s << endl;
while(s[0] == ‘ ‘)
s.erase(s.begin());
while(s[s.size() - 1] == ‘ ‘)
s.erase(s.end() - 1);
for(int i = 0; i < s.size(); ++ i) {
if(s[i] == ‘ ‘) {
while(s[i + 1] == ‘ ‘)
s.erase(s.begin() + i + 1);
if(!isalnum(s[i + 1]))
s.erase(s.begin() + i);
}
}
for(int i = 0; i < s.size(); ++ i)
if(s[i] >= ‘A‘ && s[i] <= ‘Z‘ && s[i] != ‘I‘)
s[i] += (‘a‘ - ‘A‘);
for(int beg = 0;; ++ beg) {
beg = s.find("can you", beg);
if(beg == -1) break;
if((!beg || !isalnum(s[beg - 1])) &&
(beg + 7 == s.size() || !isalnum(s[beg + 7])))
s.replace(beg, 7, "# can");
}
for(int beg = 0;; ++ beg) {
beg = s.find("could you", beg);
if(beg == -1) break;
if((!beg || !isalnum(s[beg - 1])) &&
(beg + 9 == s.size() || !isalnum(s[beg + 9])))
s.replace(beg, 9, "# could");
}
for(int beg = 0;; ++ beg) {
beg = s.find("I", beg);
if(beg == -1) break;
if((!beg || !isalnum(s[beg - 1])) &&
(beg + 1 == s.size() || !isalnum(s[beg + 1])))
s.replace(beg, 1, "you");
}
for(int beg = 0;; ++ beg) {
beg = s.find("me", beg);
if(beg == -1) break;
if((!beg || !isalnum(s[beg - 1])) &&
(beg + 2 == s.size() || !isalnum(s[beg + 2])))
s.replace(beg, 2, "you");
}
for(int i = 0; i < s.size(); ++ i) {
if(s[i] == ‘?‘) s[i] = ‘!‘;
if(s[i] == ‘#‘) s[i] = ‘I‘;
}
cout << "AI: " << s << endl;
}
return 0;
}
``````

## L2-002

``````#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5;
struct Node {
} node[maxn];
bool vis[maxn];
bool cmp(Node a, Node b) {
return a.num < b.num;
}
int main() {
int k1 = 0, k2 = 0;
for (int i = 0; i < maxn; ++ i) {
node[i].num = 2 * maxn;
}
for (int i = 0; i < n; ++ i) {
scanf("%d", &a);
scanf("%d%d", &node[a].key, &node[a].next);
}
for (int i = head; i != -1; i = node[i].next) {
if (!vis[abs(node[i].key)]) {
vis[abs(node[i].key)] = true;
node[i].num = k1;
k1 ++;
} else {
node[i].num = maxn + k2;
k2 ++;
}
}
sort(node, node + maxn, cmp);
int k = k1 + k2;
for (int i = 0; i < k; ++ i) {
if (i != k1 - 1 && i != k - 1) {
} else {
}
}
return 0;
}
``````

(0)
(0)