結果
問題 | No.267 トランプソート |
ユーザー |
|
提出日時 | 2015-10-15 00:23:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,270 bytes |
コンパイル時間 | 458 ms |
コンパイル使用メモリ | 58,052 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 15:58:40 |
合計ジャッジ時間 | 1,220 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream>#include <algorithm>#include <string>using namespace std;#define REP(i,a,b) for(i=a;i<b;i++)#define rep(i,n) REP(i,0,n)#define SQR(X) ((X)*(X))typedef long long ll;typedef unsigned long long ull;typedef long double lb;/* ここからが本編 */typedef struct{char s[10];int a;}card_sort;card_sort card[60];void card_num(int i){if('1' <= card[i].s[1] && card[i].s[1] <= '9') {card[i].a += card[i].s[1] - '0';return;}switch(card[i].s[1]) {case 'A': card[i].a += 1;break;case 'T': card[i].a += 10;break;case 'J': card[i].a += 11;break;case 'Q': card[i].a += 12;break;case 'K': card[i].a += 13;break;}}int main(void){int i,j;int n;cin >> n;rep(i,n) {cin >> card[i].s;switch(card[i].s[0]){case 'D': card[i].a = 0; break;case 'C': card[i].a = 200; break;case 'H': card[i].a = 400; break;case 'S': card[i].a = 600; break;}card_num(i);}for(i=0;i<n-1;i++) {for(j=n-1;j>i;j--) {if(card[j].a < card[j-1].a) {swap(card[j],card[j-1]);}}}cout << card[0].s;for(i=1;i<n;i++) {cout << ' ' << card[i].s;}cout << endl;return 0;}