結果

問題 No.1362 [Zelkova 8th Tune] Black Sheep
コンテスト
ユーザー monnu
提出日時 2021-01-23 01:17:28
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 448 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,508 ms
コンパイル使用メモリ 180,032 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-03 03:36:16
合計ジャッジ時間 2,550 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:8: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   21 |     S[0];
      |        ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:56,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bitset:54,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:1365:7: note: declared here
 1365 |       operator[](size_type __pos)
      |       ^~~~~~~~
main.cpp:25:13: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
   25 |   while(S[i]==c){
main.cpp:15:8: note: 'c' was declared here
   15 |   char c;
      |        ^

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 998244353
#define INF 1000000000000000000
#define MAX 2000

int main(){
  string S;
  cin>>S;
  cout<<S<<endl;
  char c;
  if(S[0]==S[1]){
    c=S[0];
  }else if(S[1]==S[2]){
    c=S[1];
  }else{
    S[0];
  }

  int i=0;
  while(S[i]==c){
    i++;
  }
  cout<<i+1<<" "<<S[i]<<endl;
}
0