結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-02-26 22:32:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,842 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 1,257 ms |
コンパイル使用メモリ | 162,492 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 14:10:21 |
合計ジャッジ時間 | 5,866 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vb = vector<bool>; using vd = vector<double>; using vl = vector<ll>; using vvi = vector<vi>; using vvb = vector<vb>; using vvd = vector<vd>; using vvl = vector<vl>; #define REP(i,n) for(ll i=0; i<(n); ++i) #define FOR(i,b,n) for(ll i=(b); i<(n); ++i) int main() { string s; cin >> s; vl index_c; vl index_w; REP(i, s.size()) { if (s[i] == 'c') index_c.push_back(i); if (s[i] == 'w') index_w.push_back(i); } ll ans = 0; for (ll i : index_c) { ll cnt = 0; for (ll j : index_w) if (j > i) ++cnt; ans += cnt * (cnt - 1) / 2; } cout << ans << endl; return 0; }