結果
| 問題 |
No.267 トランプソート
|
| コンテスト | |
| ユーザー |
y_mazun
|
| 提出日時 | 2015-08-21 22:25:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 872 bytes |
| コンパイル時間 | 682 ms |
| コンパイル使用メモリ | 72,164 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-18 11:28:58 |
| 合計ジャッジ時間 | 1,469 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int getInt()’:
main.cpp:6:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | inline int getInt(){ int s; scanf("%d", &s); return s; }
| ~~~~~^~~~~~~~~~
ソースコード
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }
#include <iostream>
#include <set>
using namespace std;
int encode(const string &s){
const char m = s[0];
const char n = s[1];
int ret = 0;
if(m == 'D') ret += 0;
if(m == 'C') ret += 1;
if(m == 'H') ret += 2;
if(m == 'S') ret += 3;
ret *= 14;
if(n == 'A') ret += 1;
else if(n == 'T') ret += 10;
else if(n == 'J') ret += 11;
else if(n == 'Q') ret += 12;
else if(n == 'K') ret += 13;
else ret += n - '0';
return ret;
}
int main(){
const int n = getInt();
vector<string> s(n);
REP(i,n) cin >> s[i];
sort(s.begin(), s.end(), [](const string &a, const string &b){
return encode(a) < encode(b);
});
REP(i,n) cout << s[i] << " "; cout << endl;
return 0;
}
y_mazun