文章

4

粉丝

0

获赞

6

访问

279

头像
后缀子串排序 题解:
P1294 上海交通大学机试题
发布于2026年2月20日 19:03
阅读数 32

利用set能自动按升序排序的特性快速求解:

#include<bits/stdc++.h>

using namespace std;

string line;

int main(){
	while(getline(cin,line)){
		set<string> s;
		for(int i=line.size()-1;i>=0;i--){
			s.insert(line.substr(i,line.size()));
		}
		for(auto t:s){
			cout<<t<<endl;
		}
	}
	
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发