結果
| 問題 |
No.267 トランプソート
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-02-01 03:17:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 906 bytes |
| コンパイル時間 | 920 ms |
| コンパイル使用メモリ | 78,048 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-18 18:50:38 |
| 合計ジャッジ時間 | 1,822 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function 'bool comp(const std::string&, std::string&)':
main.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
24 | }
| ^
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
char C1[4] = {'D','C','H','S'};
char C2[13] = {'A','2','3','4','5','6','7','8','9','T','J','Q','K'};
bool comp(const string&a,string&b){
for(int i = 0; 4 > i; i++){
if(C1[i] == a[0] && C1[i] == b[0]){
for(int j = 0; 13 > j; j++){
if(C2[j] == a[1]){
return 1;
}else if(C2[j] == b[1]){
return 0;
}
}
}else if(C1[i] == a[0]){
return 1;
}else if(C1[i] == b[0]){
return 0;
}
}
}
int main(){
int n;cin>>n;
vector<string> s(n);
for(int i = 0; n > i; i++){
cin>>s[i];
}
sort(s.begin(),s.end(),comp);
for(int i = 0; n > i; i++){
cout << s[i];
if(i+1 != n)cout << " ";
}
cout << endl;
}