Submission #69911682
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
/////////////////// メイン ///////////////////
int main () {
//////////////////// 入力 ////////////////////
string s;
cin >> s;
//////////////// 出力変数定義 ////////////////
char result = 0;
//////////////////// 処理 ////////////////////
// 正しい文字を入れる変数
char c;
// 最初3文字のうち2つは一致しているはずで、それが正しい文字
if (s.at(0)==s.at(1)) c = s.at(0);
else if (s.at(0)==s.at(2)) c = s.at(0);
else if (s.at(1)==s.at(2)) c = s.at(1);
// 正しくない文字を探す全探索
for (char c2 : s) {
if (c2!=c) result = c2;
}
//////////////////// 出力 ////////////////////
cout << result << endl;
//////////////////// 終了 ////////////////////
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - The Odd One Out |
| User | wightou |
| Language | C++ 23 (gcc 12.2) |
| Score | 200 |
| Code Size | 865 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3604 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:29:5: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
29 | if (c2!=c) result = c2;
| ^~
Main.cpp:20:8: note: ‘c’ was declared here
20 | char c;
| ^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 3536 KiB |
| sample_02.txt | AC | 1 ms | 3532 KiB |
| sample_03.txt | AC | 1 ms | 3532 KiB |
| test_01.txt | AC | 1 ms | 3472 KiB |
| test_02.txt | AC | 1 ms | 3532 KiB |
| test_03.txt | AC | 1 ms | 3472 KiB |
| test_04.txt | AC | 1 ms | 3480 KiB |
| test_05.txt | AC | 1 ms | 3468 KiB |
| test_06.txt | AC | 1 ms | 3604 KiB |
| test_07.txt | AC | 1 ms | 3472 KiB |
| test_08.txt | AC | 1 ms | 3488 KiB |
| test_09.txt | AC | 1 ms | 3464 KiB |
| test_10.txt | AC | 1 ms | 3532 KiB |
| test_11.txt | AC | 1 ms | 3472 KiB |
| test_12.txt | AC | 1 ms | 3468 KiB |
| test_13.txt | AC | 1 ms | 3444 KiB |
| test_14.txt | AC | 1 ms | 3536 KiB |
| test_15.txt | AC | 1 ms | 3484 KiB |
| test_16.txt | AC | 1 ms | 3488 KiB |
| test_17.txt | AC | 1 ms | 3484 KiB |
| test_18.txt | AC | 1 ms | 3600 KiB |
| test_19.txt | AC | 1 ms | 3464 KiB |
| test_20.txt | AC | 1 ms | 3604 KiB |
| test_21.txt | AC | 1 ms | 3448 KiB |
| test_22.txt | AC | 1 ms | 3448 KiB |
| test_23.txt | AC | 1 ms | 3540 KiB |
| test_24.txt | AC | 1 ms | 3536 KiB |