結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
xyz600600
|
| 提出日時 | 2016-03-19 04:36:03 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 520 bytes |
| 記録 | |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 75,120 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-12 16:21:18 |
| 合計ジャッジ時間 | 1,391 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main()
{
string s;
getline( cin, s );
const int INIT = 10000;
int ans = INIT;
for( int i = 0; i < s.size(); i++ )
{
if ( s[i] == 'c' )
{
for( int j = i + 1; j < s.size(); j++ )
{
if ( s[j] == 'w' )
{
for( int k = j + 1; k < s.size(); k++ )
{
if ( s[k] == 'w' )
{
ans = min( ans, k - i + 1 );
}
}
}
}
}
}
if ( ans == INIT )
{
cout << -1 << endl;
}
else
{
cout << ans << endl;
}
}
xyz600600