結果
| 問題 |
No.1362 [Zelkova 8th Tune] Black Sheep
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-11 13:42:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 1,000 ms |
| コード長 | 537 bytes |
| コンパイル時間 | 1,418 ms |
| コンパイル使用メモリ | 168,884 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-13 02:20:02 |
| 合計ジャッジ時間 | 2,763 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:29:27: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
29 | cout << res << " " << ans << endl;
| ^~~
main.cpp:13:18: note: 'ans' was declared here
13 | char c = s[0], ans;
| ^~~
main.cpp:29:27: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
29 | cout << res << " " << ans << endl;
| ^~~
main.cpp:14:7: note: 'res' was declared here
14 | int res;
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
int main(void)
{
string s;
cin >> s;
vector<int> cnt(2, 0);
cnt[0]++;
char c = s[0], ans;
int res;
for (int i = 1; i < s.size(); i++)
{
if (s[i] == c)
{
cnt[0]++;
}
else
{
cnt[1]++;
res = i + 1;
ans = s[i];
}
}
if (cnt[0] > cnt[1])
cout << res << " " << ans << endl;
else
cout << 1 << " " << c << endl;
return 0;
}