QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#647950#5440. P-P-PalindromeCure_BeautyTL 4ms35120kbC++141.8kb2024-10-17 16:19:132024-10-17 16:19:28

Judging History

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

  • [2024-10-17 16:19:28]
  • 评测
  • 测评结果:TL
  • 用时:4ms
  • 内存:35120kb
  • [2024-10-17 16:19:13]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
using std::cin;using std::cout;
constexpr int N=1000006;
int n,l;
std::string s[N];
bool tag=1;
namespace sub1_2{
	int ans=0;
	signed main(){
		for(int i=1;i<=n;++i) ans=std::max(ans,(int)s[i].size());
		cout<<1ll*ans*ans<<'\n';
		return 0;
	}
}
namespace sub3{
	std::vector<std::string>w;
	std::map<std::string,bool>g;
	int ans;
	signed main(){
		for(int i=1;i<=n;++i)
			for(int j=0;j<s[i].size();++j){
				std::string t="";
				t+=s[i][j];
				if(!g[t]){w.push_back(t);g[t]=1;}
				for(int k=1;j-k>=0&&j+k<s[i].size();++k){
					if(s[i][j-k]!=s[i][j+k]) break;
					t=s[i][j-k]+t+s[i][j+k];
					if(!g[t]){w.push_back(t);g[t]=1;}
				}
				if(j+1==s[i].size()) break;
				if(s[i][j]!=s[i][j+1]) continue;
				t="";t+=s[i][j];t+=s[i][j+1];
				if(!g[t]){w.push_back(t);g[t]=1;}
				for(int k=1;j-k>=0&&j+k+1<s[i].size();++k){
					if(s[i][j-k]!=s[i][j+k+1]) break;
					t=s[i][j-k]+t+s[i][j+k+1];
					if(!g[t]){w.push_back(t);g[t]=1;}
				}
			}
		for(auto i:w)
			for(auto j:w){
				std::string t=i+j;
				bool tag=1;
				for(int j=0;j<t.size()/2;++j) if(t[j]!=t[t.size()-j-1]){tag=0;break;}
				ans+=tag;
			}
		cout<<ans;
		return 0;
	}
}
signed main(){
//	freopen("string.in","r",stdin);
//	freopen("string.out","w",stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);cout.tie(nullptr);
	cin>>n;
	for(int i=1;i<=n;++i){cin>>s[i];l+=s[i].size();}
	for(int i=1;i<=n;++i) for(int j=0;j<s[i].size();++j) if(s[i][j]!='a'){tag=0;break;}
	if(tag) return sub1_2::main();
	if(l<=1000) return sub3::main();
	return sub3::main();cout<<"犬饲彩羽";
}//第一百五回 锦衣军查抄宁国府 骢马使弹劾平安州

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 34816kb

input:

2
aaaa
aaa

output:

16

result:

ok 1 number(s): "16"

Test #2:

score: 0
Accepted
time: 3ms
memory: 35112kb

input:

3
abaaa
abbbba
bbbaba

output:

28

result:

ok 1 number(s): "28"

Test #3:

score: 0
Accepted
time: 4ms
memory: 34948kb

input:

1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab

output:

15130

result:

ok 1 number(s): "15130"

Test #4:

score: 0
Accepted
time: 4ms
memory: 35120kb

input:

3
aaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbb
bababababababaabababababa

output:

1282

result:

ok 1 number(s): "1282"

Test #5:

score: -100
Time Limit Exceeded

input:

5
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:


result: