結果
| 問題 | No.587 七対子 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-03 22:30:27 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 385µs | |
| コード長 | 548 bytes |
| 記録 | |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 86,528 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-18 23:26:45 |
| 合計ジャッジ時間 | 2,055 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:35:11: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
35 | cout << ans << endl;
| ^~~
main.cpp:17:8: note: 'ans' was declared here
17 | char ans;
| ^~~
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> cnt(256);
for (char c : s) {
cnt[c]++;
}
char ans;
int uniq = 0;
for (int i = 0; i < 256; i++) {
if (cnt[i] == 1) {
ans = i;
} else if (cnt[i] > 2) {
cout << "Impossible" << endl;
return 0;
}
if (1 <= cnt[i] && cnt[i] <= 2) {
uniq++;
}
}
if (uniq != 7) {
cout << "Impossible" << endl;
return 0;
}
cout << ans << endl;
}