結果
| 問題 |
No.587 七対子
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-03 22:24:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 540 bytes |
| コンパイル時間 | 1,447 ms |
| コンパイル使用メモリ | 158,228 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 19:38:39 |
| 合計ジャッジ時間 | 1,973 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:23: warning: ‘v’ may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | printf("%c\n",('a'+v));
| ~~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
string s;
int cnt[28];
int main(void){
cin >> s;
int n=s.size();
for(int i=0;i<n;i++){
cnt[s[i]-'a']++;
}
bool flag=true;
int two=0,one=0;
int v;
for(int i=0;i<26;i++){
if(cnt[i]>2){
flag=false;
}
if(cnt[i]==2)two++;
if(cnt[i]==1){
one++;
v=i;
}
}
if(one>=2 || two!=6)flag=false;
if(one!=1)flag=false;
if(flag){
printf("%c\n",('a'+v));
}else{
printf("Impossible\n");
}
return 0;
}