QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#176574 | #5680. You You See What? | wiseman123 | WA | 1ms | 3800kb | C++14 | 1.4kb | 2023-09-11 19:55:56 | 2023-09-11 19:55:57 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int vis[300],b[300],st[300][300],p[300][300];
string tran(string s)
{
int len=s.size();
for(int i=0;i<len;i++)
{
s[i]=tolower(s[i]);
}
return s;
}
bool check(int l,int r)
{
if(l>=r) return true;
if(b[l]!=b[r]) return false;
if(st[l][r]) return p[l][r];
st[l][r]=1;
return p[l][r]=check(l+1,r-1);
}
int main()
{
string s;
cin>>s;
int len=(int) s.size();
vector<string> a;
for(int i=0,j=0;i<=len;i++)
{
if(i==len||s[i]=='!')
{
a.push_back(s.substr(j,i-j));
j=i+1;
}
}
//给字符串标号
int n=a.size(),cnt=0;
map<string,int> mp;
for(int i=0;i<n;i++)
{
string t=tran(a[i]);
if(!mp.count(t))
{
mp[t]=++cnt;
}
b[i]=mp[t];
}
//判断回文
for(int i=0;i<n;i++)
{
for(int j=n-1;j>i;j--)
{
int l=i,r=j;
if(check(i,j))
{
//cout<<i<<" "<<j<<endl;
vis[i+1]+=1;
vis[j+1]-=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<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3516kb
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: 0ms
memory: 3496kb
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: 0ms
memory: 3520kb
input:
bresearch!bpoucher
output:
bresearch!bpoucher
result:
ok single line: 'bresearch!bpoucher'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3800kb
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: 0ms
memory: 3684kb
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: 3624kb
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: 0ms
memory: 3460kb
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: 0
Accepted
time: 0ms
memory: 3548kb
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!abc
result:
ok single line: 'abcdEFGHij!abc'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb
output:
a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb
result:
ok single line: 'a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!...!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!B
output:
aa!B
result:
ok single line: 'aa!B'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
b
output:
b
result:
ok single line: 'b'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
bpoucher
output:
bpoucher
result:
ok single line: 'bpoucher'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
Abcdefghij
output:
Abcdefghij
result:
ok single line: 'Abcdefghij'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
polyof!johnb
output:
polyof!johnb
result:
ok single line: 'polyof!johnb'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
polyvm!polyof!gracie!johnb
output:
polyvm!polyof!gracie!johnb
result:
ok single line: 'polyvm!polyof!gracie!johnb'
Test #16:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
a!b!b!c!c!d!d!d!e!e!e
output:
a!b!c!d!e
result:
wrong answer 1st lines differ - expected: 'a!b!c!d!e!e', found: 'a!b!c!d!e'