結果

問題 No.267 トランプソート
ユーザー IL_mstaIL_msta
提出日時 2015-08-21 22:49:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,816 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 90,924 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 15:01:16
合計ジャッジ時間 1,854 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:51:9: warning: ‘temp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    temp += c2 -'0';
    ~~~~~^~~~~~~~~~

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	int N;
	cin>>N;
	char c1,c2;
	vector<int> v;
	v.resize(N);
	int temp;
	rep(i,N){
		cin>>c1>>c2;
		if(c1 == 'D'){temp = 100;}
		else if(c1 == 'C'){temp = 200;}
		else if(c1 == 'H'){temp = 300;}
		else if(c1 == 'S'){temp = 400;}
		if( '2' <= c2 && c2 <= '9'){
			temp += c2 -'0';
		}else if( c2 == 'A'){
			temp += 1;
		}else if( c2 == 'T'){temp+=10;}
		else if( c2 == 'J'){temp+=11;}
		else if( c2 == 'Q'){temp+=12;}
		else if( c2 == 'K'){temp+=13;}
		v[i] = temp;
	}
	sort(v.begin(),v.end() );
	vector<int>::iterator it = v.begin();
	while( it != v.end() ){
		switch(*it/100){
			case 1:cout<<'D';break;
			case 2:cout<<'C';break;
			case 3:cout<<'H';break;
			case 4:cout<<'S';break;
		}
		switch(*it%100){
			case 1:cout<<'A';break;
			case 2:cout<<'2';break;
			case 3:cout<<'3';break;
			case 4:cout<<'4';break;
			case 5:cout<<'5';break;
			case 6:cout<<'6';break;
			case 7:cout<<'7';break;
			case 8:cout<<'8';break;
			case 9:cout<<'9';break;
			case 10:cout<<'T';break;
			case 11:cout<<'J';break;
			case 12:cout<<'Q';break;
			case 13:cout<<'K';break;
		}
		if((it+1) != v.end() ){
			cout << " ";
		}else{
			cout << endl;
		}
		++it;
	}
	return 0;
}
0