結果
| 問題 |
No.548 国士無双
|
| コンテスト | |
| ユーザー |
Elk
|
| 提出日時 | 2018-06-30 01:42:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 990 bytes |
| コンパイル時間 | 1,540 ms |
| コンパイル使用メモリ | 178,388 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 14:51:28 |
| 合計ジャッジ時間 | 2,227 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:37:24: warning: 'tmp' may be used uninitialized [-Wmaybe-uninitialized]
37 | cout << abc[tmp] << endl;
| ^
main.cpp:10:9: note: 'tmp' was declared here
10 | int tmp;
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
map <char, int> mp;
string str;
string abc = "abcdefghijklm";
int cnt = 0, cnt2[13] = {0};
char daburi = 0;
int tmp;
cin >> str;
sort(str.begin(), str.end());
for(int i = 0; i < 13; i++){
cnt2[str[i] - 'a']++;
}
for(int i = 0; i < 13; i++){
if(cnt2[i] == 0){
tmp = i;
break;
}
}
for(int i = 0; i < str.size(); i++){
mp[str[i]]++;
}
for(auto itr = mp.begin(); itr != mp.end(); itr++){
if(itr->second != 0){
cnt++;
}
if(itr->second == 2){
daburi = itr->first;
}
}
if(daburi != 0 && cnt == 12){
cout << abc[tmp] << endl;
}else if(daburi == 0 && cnt == 13){
for(auto itr = mp.begin(); itr != mp.end(); itr++){
cout << itr->first << endl;
}
}else{
cout << "Impossible" << endl;
}
return 0;
}
Elk