結果

問題 No.345 最小チワワ問題
ユーザー 👑 NachiaNachia
提出日時 2020-10-06 22:18:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 167,192 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-20 03:04:02
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    string S; cin >> S;
    int N = S.size();
    int ans = N + 1;
    rep(i, N) rep(j, i) rep(k, j)
        if (S[i] == 'w') if (S[j] == 'w') if (S[k] == 'c')
            ans = min(ans, i - k + 1);
    if (ans == N + 1) cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}
0