結果

問題 No.587 七対子
ユーザー MiyanagaTeruMiyanagaTeru
提出日時 2019-10-05 20:48:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,108 bytes
コンパイル時間 2,285 ms
コンパイル使用メモリ 200,568 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-27 02:31:56
合計ジャッジ時間 3,771 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,388 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,384 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:68:41: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   68 |     if(cnt2 == 6 and cnt1 == 1) cout << ans << endl;
      |                                         ^~~
main.cpp:63:34: 備考: ‘ans’ はここで定義されています
   63 |     int cnt2 = 0, cnt1 = 0; char ans;
      |                                  ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

#define MAX_N 10005
int prime[MAX_N]; //i番目の素数
bool is_prime[MAX_N+1]; //is_prime[i]==true->iはprime

//n以下の素数の数を返す
void sieve(int n) {
    int p = 0;
    rep(i,n+1) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep2(i,n+1) {
        if(is_prime[i]) {
            prime[p++] = i;
            for(int j = 2 * i; j<= n; j+= i) is_prime[j] = false;
        }
    }
    return ;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

    string S; cin >> S;
    vei cnt(26, 0);
    rep(i,S.size()) cnt[S[i]-'a']++;
    int cnt2 = 0, cnt1 = 0; char ans;
    rep(i,26) {
        if(cnt[i] == 1) { cnt1++; ans = (char)(i + 'a'); }
        if(cnt[i] == 2) cnt2++;
    }
    if(cnt2 == 6 and cnt1 == 1) cout << ans << endl;
    else cout << "Impossible" << endl;
    return 0;
    
}

0