結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2019-11-19 21:05:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 464 bytes |
コンパイル時間 | 1,432 ms |
コンパイル使用メモリ | 168,088 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 07:54:02 |
合計ジャッジ時間 | 2,501 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; int main(){ string s; cin >> s; int n = sz(s); vector<int> cum(n+1, 0); ll res = 0; for (int i = n-1; i >= 0; i--) { if (s[i] == 'w') cum[i] = cum[i+1] + 1; else cum[i] = cum[i+1]; if (s[i] == 'c') res += cum[i] * (cum[i] - 1) / 2; } cout << res << endl; return 0; }