結果

問題 No.587 七対子
ユーザー toto6114
提出日時 2019-07-02 18:33:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 78,232 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 19:59:27
合計ジャッジ時間 1,490 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:24:15: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   24 |       cout << ans << endl;
      |               ^~~
main.cpp:13:8: note: 'ans' was declared here
   13 |   char ans;
      |        ^~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  string s;
  cin >> s;
  map<char,int> mp;
  for(int i=0; i<s.size(); i++) {
      mp[s[i]]++;
  }
  int a=0, b=0;
  char ans;
  for(auto p:mp) {
      if(p.second==2) {
          b++;
      }
      if(p.second==1) {
          a++;
          ans=p.first;
      }
  }
  if(b==6&&a==1) {
      cout << ans << endl;
  }
  else {
      cout << "Impossible" << endl;
  }
}
0