QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#176566 | #5680. You You See What? | wiseman123 | WA | 0ms | 3440kb | C++14 | 1.4kb | 2023-09-11 19:52:19 | 2023-09-11 19:52:21 |
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(tran(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+="!";
}
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3440kb
input:
texasam!rice!baylor!csdept!baylor!rice!dev!bresearch!bpoucher
output:
1 5 2 4 texasam!rice!dev!bresearch!bpoucher!
result:
wrong answer 1st lines differ - expected: 'texasam!rice!dev!bresearch!bpoucher', found: '1 5'