結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-26 23:13:51 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
RE
不安定
|
| 実行時間 | - |
| コード長 | 552 bytes |
| 記録 | |
| コンパイル時間 | 356 ms |
| コンパイル使用メモリ | 88,064 KB |
| 実行使用メモリ | 7,724 KB |
| 最終ジャッジ日時 | 2026-09-02 20:03:39 |
| 合計ジャッジ時間 | 8,558 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | WA * 1 RE * 3 TLE * 1 -- * 18 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:19:22: warning: 'w' may be used uninitialized [-Wmaybe-uninitialized]
19 | if (c=='w') w+=1;
| ~^~~
main.cpp:13:13: note: 'w' was declared here
13 | int c,i,w,j,n;
| ^
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int fact(int n){int i,j;for(i=1,j=1;i<n;j*=i)i++;return j;}
int combi(int x,int k){return fact(x)/(fact(k)*fact(x-k));}
int main(){
int c,i,w,j,n;
int s[100005];
i=0;
while((c=getchar())!=-1){
s[i++]=c;
if (c=='w') w+=1;
}
n=0;
for (j=0;j<i;j++){
if (w<=1) break;
if (s[j]=='c') n+=combi(w,2);
if (s[j]=='w') w-=1;
}
cout<<n<<endl;
return 0;
}