結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-02-26 23:13:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 631 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 22:57:07 |
合計ジャッジ時間 | 1,514 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <list> #include <typeinfo> using namespace std; #define REP(a,b) for(long long a = 0;a < b;++a) int main() { string joke; cin >> joke; string s; for (int i = joke.length()-1;i >= 0;--i) { s.push_back(joke[i]); } long long ans = 0; long long counter_w = 0; for (int i = 0;i < s.length();++i) { if (s[i] == 'w') { counter_w++; } else if (s[i] == 'c') { if (counter_w >= 2) ans += counter_w*(counter_w - 1) / 2; } } cout << ans << endl; } //thank you for reading my code