結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
|
提出日時 | 2024-11-12 15:09:54 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 394 bytes |
コンパイル時間 | 857 ms |
コンパイル使用メモリ | 68,096 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-12 15:10:07 |
合計ジャッジ時間 | 2,084 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream>#include <cstdint>using namespace std;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);string S;cin >> S;int64_t ans = 0;for (int32_t i = S.size() - 1, count = 0; i != -1; --i)switch (S[i]){case 'w':++count;break;case 'c':ans += count * static_cast<int64_t>(count - 1) / 2;break;}cout << ans << '\n';return 0;}