結果
問題 | No.267 トランプソート |
ユーザー |
|
提出日時 | 2019-01-04 05:33:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 673 bytes |
コンパイル時間 | 2,127 ms |
コンパイル使用メモリ | 177,812 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 22:58:54 |
合計ジャッジ時間 | 2,715 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function 'bool comp(std::string, std::string)': main.cpp:11:34: warning: 'yy' may be used uninitialized [-Wmaybe-uninitialized] 11 | if(xx != yy) return xx < yy; | ^~ main.cpp:6:17: note: 'yy' was declared here 6 | int xx, yy; | ^~ main.cpp:11:34: warning: 'xx' may be used uninitialized [-Wmaybe-uninitialized] 11 | if(xx != yy) return xx < yy; | ^~ main.cpp:6:13: note: 'xx' was declared here 6 | int xx, yy; | ^~
ソースコード
#include <bits/stdc++.h>using namespace std;bool comp(string x, string y) {string a = "DCHS", b = "A23456789TJQK";int xx, yy;for(int i = 0; i < a.size(); i++) {if(x[0] == a[i]) xx = i;if(y[0] == a[i]) yy = i;}if(xx != yy) return xx < yy;xx = 0; yy = 0;for(int i = 0; i < b.size(); i++) {if(x[1] == b[i]) xx += i;if(y[1] == b[i]) yy += i;}return xx < yy;}int main() {ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;vector<string> s(n);for(int i = 0; i < n; i++) {cin >> s[i];}sort(s.begin(), s.end(), comp);for(int i = 0; i < n; i++) {if(i > 0) cout << " ";cout << s[i];}cout << endl;return 0;}