結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-05-27 02:05:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,003 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 72,868 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:46:44 |
合計ジャッジ時間 | 1,468 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <set> #include <map> #include <queue> #include <stack> #include <climits> #include <cassert> #include <cmath> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define INF INT_MAX/3 #define LINF LLONG_MAX/3 #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(v) (v).begin(),(v).end() #define debug(x) cout<<#x<<":"<<x<<endl #define debug2(x,y) cout<<#x<<","<<#y":"<<x<<","<<y<<endl typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; int main(){ string s;cin>>s; int n=s.size(); int ans=INF; for(int i=0;i<n;i++) if(s[i]=='c'){ int c=0; for(int j=i+1;j<n;j++) if(s[j]=='w'){ c++; if(c==2) ans=min(ans,j-i+1); } } if(ans==INF) cout << -1 << endl; else cout << ans << endl; return 0; }