結果

問題 No.436 ccw
ユーザー treeonetreeone
提出日時 2016-10-28 22:22:37
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 159,140 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 05:36:05
合計ジャッジ時間 2,179 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:21: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     int ans = min(c - 1, w);
      |                   ~~^~~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    string s;
    cin >> s;
    int c, w;
    rep(i, 0, s.size()){
        if(s[i] == 'w'){
            c = i;
            break;
        }
    }
    w = s.size() - c;
    int ans = min(c - 1, w);
    o(ans);
}
0