結果

問題 No.3487 Restricted Shiritori
コンテスト
ユーザー daiota
提出日時 2026-04-01 22:47:55
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 495 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,279 ms
コンパイル使用メモリ 212,264 KB
実行使用メモリ 218,140 KB
最終ジャッジ日時 2026-04-01 22:48:00
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:44,
                 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:
In static member function 'static constexpr void std::char_traits<char>::assign(char_type&, const char_type&)',
    inlined from 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:1729:21,
    inlined from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:1499:17,
    inlined from 'int main()' at main.cpp:52:16:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/char_traits.h:352:14: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
  352 |         __c1 = __c2;
      |         ~~~~~^~~~~~
main.cpp: In function 'int main()':
main.cpp:40:14: note: 'c' was declared here
   40 |         char c;
      |              ^

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
















int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;




	ll N;
	char s,e;
	cin >> s >> e >> N;

	if(N==1){
		cout << -1 << endl;
		return 0;
	}

	char c;
	REP(i,26){
		char d='a'+i;
		if(d!=s && d!=e){
			c=d;
			break;
		}
	}


	string x;
	x+=s;
	REP(i,N-2) x+=c;
	x+=e;


	cout << x << endl;










	return 0;

}
0