How C
  • 板块学术版
  • 楼主HappyCode
  • 当前回复4
  • 已保存回复5
  • 发布时间2024/3/16 21:40
  • 上次更新2024/3/16 22:58:37
查看原帖
How C
546369
HappyCode楼主2024/3/16 21:40

ABC345 C

暴力枚举:

#include<iostream>
#include<string>
#include<unordered_map>
using namespace std;
string s;
int n;
unordered_map<string,bool> st;
int main(){
	cin>>s;
	n=s.length();
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			string t=s;
			char tmp=t[i];
			t[i]=t[j];
			t[j]=tmp;
			st[t]=true;
		}
	}
	cout<<st.size()<<endl;
	return 0;
}

会 TLEx13。

2024/3/16 21:40
加载中...