結果
| 問題 | No.8116 TCP ソート | 
| コンテスト | |
| ユーザー |  kokosei | 
| 提出日時 | 2025-04-05 01:02:06 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 530 bytes | 
| コンパイル時間 | 1,045 ms | 
| コンパイル使用メモリ | 96,372 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-04-05 01:02:09 | 
| 合計ジャッジ時間 | 2,475 ms | 
| ジャッジサーバーID (参考情報) | judge6 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
string S;
int main(void){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> S;
	bool f = false;
	for(char c : S)if(c == 'C')f = true;
	sort(S.begin(), S.end(), [](char a, char b){
		if(a == 'T' && b == 'C'){
			return 1;
		}
		if(a == 'C' && b == 'P'){
			return 1;
		}
		if(a == 'T' && b == 'P'){
			return 1;
		}
		return 0;
	});
	if(f){
		cout << S << endl;
	}else{
		reverse(S.begin(), S.end());
		cout << S << endl;
	}
	return 0;
}
            
            
            
        