QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#175545 | #5680. You You See What? | Ashoka | WA | 1ms | 3624kb | C++20 | 1.1kb | 2023-09-10 19:30:41 | 2023-09-10 19:30:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
vector<string> a;
int len = (int)s.size();
for (int i = 0, j = 0; i <= len; ++i) {
if (i == len || s[i] == '!') {
a.emplace_back(s.substr(j, i - j));
j = i + 1;
}
}
int n = a.size();
map<string, int> mp;
int cnt = 0;
vector<int> b(n);
for (int i = 0; i < n; ++i) {
string t = "";
for (auto c : a[i]) {
t += tolower(c);
}
if (!mp.count(t)) {
mp[t] = ++cnt;
}
b[i] = mp[t];
}
vector<int> vis(n);
for (int i = 0; i < n; ++i) {
for (int j = n - 1; j > i; --j) {
int l = i, r = j;
while (l < r && b[l] == b[r]) {
++l, --r;
}
if (l >= r) {
vis[i] += 1;
vis[j] -= 1;
}
}
}
for (int i = 1; i < n; ++i) {
vis[i] += vis[i - 1];
}
string ans = "";
for (int i = 0; i < n; ++i) {
if (!vis[i]) {
ans += a[i];
ans += '!';
}
}
ans.pop_back();
cout << ans << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3624kb
input:
texasam!rice!baylor!csdept!baylor!rice!dev!bresearch!bpoucher
output:
texasam!rice!dev!bresearch!bpoucher
result:
ok single line: 'texasam!rice!dev!bresearch!bpoucher'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3608kb
input:
texasam!Rice!baYlor!csdept!BayloR!dev!Rice!bresearch!bpoucher
output:
texasam!Rice!BayloR!dev!Rice!bresearch!bpoucher
result:
wrong answer 1st lines differ - expected: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher', found: 'texasam!Rice!BayloR!dev!Rice!bresearch!bpoucher'