結果
| 問題 |
No.1362 [Zelkova 8th Tune] Black Sheep
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-22 21:41:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 1,000 ms |
| コード長 | 947 bytes |
| コンパイル時間 | 808 ms |
| コンパイル使用メモリ | 94,160 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 22:56:36 |
| 合計ジャッジ時間 | 2,275 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:51:33: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
51 | cout << k + 1 << " " << a << endl;
| ^
main.cpp:27:14: note: 'a' was declared here
27 | char a;
| ^
main.cpp:51:33: warning: 'k' may be used uninitialized [-Wmaybe-uninitialized]
51 | cout << k + 1 << " " << a << endl;
| ^
main.cpp:26:13: note: 'k' was declared here
26 | int k;
| ^
ソースコード
#define _USE_MATH_DEFINES
#include <iostream> //cin, cout
#include <vector> //vector
#include <algorithm> //sort,min,max,count
#include <string> //string,getline, to_string
#include <ios> //fixed
#include <iomanip> //setprecision
#include <utility> //swap, pair
#include <cstdlib> //abs(int)
#include <cmath> //sqrt,ceil,M_PI, pow, sin
#include <sstream> //stringstream,getline
#include <numeric> //gcd, accumlate
#include <deque> //deque
#include <random> //randam_device
#include <limits> //numeric_limits
using namespace std;
constexpr long long int D_MOD = 1000000007;
int main() {
string S;
cin >> S;
int k;
char a;
char same;
if (S[0] == S[1]) {
same = S[0];
for (unsigned int i = 0; i < S.length(); i++) {
if (S[i] != same) {
k = i;
a = S[i];
break;
}
}
}
else {
if (S[0] == S[2]) {
k = 1;
a = S[1];
}
else {
k = 0;
a = S[0];
}
}
cout << k + 1 << " " << a << endl;
return 0;
}