結果

問題 No.587 七対子
コンテスト
ユーザー tenkyu9
提出日時 2018-03-25 20:19:28
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 757 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 942 ms
コンパイル使用メモリ 104,056 KB
実行使用メモリ 110,456 KB
最終ジャッジ日時 2026-04-02 18:09:51
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:48:22: warning: 't' may be used uninitialized [-Wmaybe-uninitialized]
   48 |         cout << abc[t] << endl;
      |                      ^
main.cpp:37:13: note: 't' was declared here
   37 |         int t;
      |             ^

ソースコード

diff #
raw source code

#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