結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
togari_takamoto
|
| 提出日時 | 2016-02-26 22:35:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 731 bytes |
| コンパイル時間 | 1,293 ms |
| コンパイル使用メモリ | 162,032 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 14:11:52 |
| 合計ジャッジ時間 | 2,134 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
#define ALL(v) (v).begin(), (v).end()
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 = index_w.end() - upper_bound(ALL(index_w), i);
ans += cnt * (cnt - 1) / 2;
}
cout << ans << endl;
return 0;
}
togari_takamoto