結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
xyz600600
|
| 提出日時 | 2016-03-19 04:36:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 520 bytes |
| コンパイル時間 | 549 ms |
| コンパイル使用メモリ | 57,976 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 11:39:20 |
| 合計ジャッジ時間 | 1,538 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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