QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#176571#5680. You You See What?wiseman123WA 0ms3860kbC++141.4kb2023-09-11 19:54:522023-09-11 19:54:54

Judging History

你现在查看的是最新测评结果

  • [2023-09-11 19:54:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3860kb
  • [2023-09-11 19:54:52]
  • 提交

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+="!";
    	}
    }
    ans.pop_back();
    cout<<ans<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: -100
Wrong Answer
time: 0ms
memory: 3860kb

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'