QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#175683 | #5680. You You See What? | yyc4591 | WA | 1ms | 3868kb | C++14 | 1.6kb | 2023-09-10 21:28:59 | 2023-09-10 21:28:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
map<string, int>mp;
int id = 1;
map<int, string>src;
void deal(string &s)
{
for(auto &it : s)
{
if(it == '!')
it = ' ';
}
}
string convert(string t)
{
string s = t;
for(auto &it : s)
if(it >= 'A' && it <= 'Z')
it = it - 'A' + 'a';
return s;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
string s; cin >> s;
deal(s);
vector<int>v; v.clear();
stringstream is(s);
auto print = [&]()
{
cout << src[v[0]];
for(int i = 1; i <v.size(); i++)
cout << "!" << src[v[i]];
cout << endl;
};
string t;
while(is >> t)
{
string str = convert(t);
if(!mp.count(str)) {
src[id] = t;
mp[str] = id++;
}
v.push_back(mp[str]);
}
int n = v.size();
while(1)
{
int len = 1, loc = -1;
for(int i = 2; i < n - 1; i++)
{
int sum = 1, cnt;
if(v[i] == v[i + 1]) {
for(cnt = 1; i - cnt >= 1 && i + cnt + 1 < n; cnt++)
if(v[i - cnt] != v[i + cnt + 1])
break;
sum = max(cnt * 2, sum);
}
else {
for(cnt = 1; i - cnt >= 1 && i + cnt < n; cnt++)
if(v[cnt + i] != v[i - cnt])
break;
sum = max(sum, cnt * 2 - 1);
}
if(sum > len) {
len = sum;
loc = i;
}
}
// cout << len << " " << loc << endl;
if(loc == -1)break;
int st, ed;
if(v[loc] == v[loc + 1]) {
st = loc - len/2 + 2;
ed = loc + len/2 + 1;
}
else {
st = loc - len / 2 + 1;
ed = loc + len / 2 + 1;
}
v.erase(v.begin() + st, v.begin() + ed);
n = v.size();
// print();
}
print();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
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: 0
Accepted
time: 1ms
memory: 3632kb
input:
texasam!Rice!baYlor!csdept!BayloR!dev!Rice!bresearch!bpoucher
output:
texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher
result:
ok single line: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
bresearch!bpoucher
output:
bresearch!bpoucher
result:
ok single line: 'bresearch!bpoucher'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x
output:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x
result:
ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx
output:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx
result:
ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z
output:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z
result:
ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc
output:
abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc
result:
ok single line: 'abcdEFGHij!bbcdEFGHij!cbcdEFGH...FGHij!vbcdEFGHij!wbcdEFGHij!abc'
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3868kb
input:
abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abc
output:
abcdEFGHij!abcdEFGHij!abc
result:
wrong answer 1st lines differ - expected: 'abcdEFGHij!abc', found: 'abcdEFGHij!abcdEFGHij!abc'