結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
Bantako
|
| 提出日時 | 2017-07-16 21:23:06 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 506 bytes |
| 記録 | |
| コンパイル時間 | 312 ms |
| コンパイル使用メモリ | 40,868 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-04-24 12:18:53 |
| 合計ジャッジ時間 | 2,682 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main(){
| ^~~~
ソースコード
#include<stdio.h>
#include<string.h>
int num[100000];
char S[100001];
main(){
int sum = 0;
int count = 0;//cの数
scanf("%s",S);
for(int i = 0;i < strlen(S);i++){
if(S[i]=='c'){
num[count] = sum;
count++;
}
if(S[i]=='w'){
sum++;
}
}
long long ans = 0;
for(int i = 0;i < count;i++){
long long a = sum-num[i];
if(a >= 2){
ans += a*(a-1)/2;
}
}
printf("%lld\n",ans);
}
Bantako