結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
amtgjw
|
| 提出日時 | 2018-05-23 09:37:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 731 bytes |
| コンパイル時間 | 593 ms |
| コンパイル使用メモリ | 73,796 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 16:06:38 |
| 合計ジャッジ時間 | 1,842 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 2 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <complex>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPS(i,s,t) for(int i=(s);i<(t);++i)
#define INF 2000000007
#define MOD 1000000007
#define MAX 100005
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
int dp[MAX];
int comb[MAX];
int main(){
string str;cin>>str;
int len = str.size();
REPS(i,2,len) comb[i] = i*(i-1)/2;
for(int i=len;i>0;--i) dp[i] = dp[i+1] + (str[i-1]=='w' ? 1 : 0);
ull ans = 0;
REPS(i,1,len+1){
if(str[i-1]=='c'){
ans += comb[dp[i]];
}
}
cout << ans << endl;
return 0;
}
amtgjw