結果

問題 No.587 七対子
ユーザー tenkyu9
提出日時 2018-03-25 20:19:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-19 19:51:50
合計ジャッジ時間 1,865 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:22: warning: ‘t’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |         cout << abc[t] << endl;
      |                      ^

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){
	
	int x[26]={0};
	string s;
	string abc="abcdefghijklmnopqrstuvwxyz";
	cin >> s;
	
	for(int i=0; i<13; i++){
		for(int j=0; j<26; j++){
			if(s[i]==abc[j]){
				x[j]++;
			}
		}
	}
	for(int i=0; i<26; i++){
		if(x[i]>2){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	bool flag=false;
	int t;
	for(int i=0; i<26; i++){
		if(flag && x[i]==1){
			cout << "Impossible" << endl;
			return 0;
		}
		if(!flag && x[i]==1){
			t=i;
			flag=true;
		}
	}
	cout << abc[t] << endl;

  return 0;
}
0