結果
| 問題 |
No.1196 A lazy student
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2020-08-25 00:09:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 77 ms / 1,000 ms |
| コード長 | 1,653 bytes |
| コンパイル時間 | 2,124 ms |
| コンパイル使用メモリ | 194,684 KB |
| 最終ジャッジ日時 | 2025-01-13 13:39:09 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N;
double P,Q,R;
string S,T;
char* C;
double expression();
double exp2() {
if(*C=='Y') {
C++;
return 1;
}
if(*C=='N') {
C++;
return 0;
}
if(*C=='(') {
C++;
double A=expression();
C++;
return A;
}
C++;
double A=expression();
double B=expression();
C++;
return A*B*P+(1-A)*(1-B)*Q;
}
double exp1() {
double A=exp2();
while(*C=='A') {
C++;
double B=exp1();
A=A*B;
A=R*A+(1-R)*(1-A);
}
return A;
}
double expression() {
double A=exp1();
while(*C=='O') {
C++;
double B=exp1();
A=1-(1-A)*(1-B);
A=R*A+(1-R)*(1-A);
}
return A;
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
cin>>P>>Q>>R;
cin>>S;
FOR(i,N) {
if(S[i]=='Y') T+='Y';
else if(S[i]=='N') T+='N';
else if(S[i]=='(') T+="(";
else if(S[i]==')') T+=")";
if(S[i]=='a') {
T+='A';
i+=2;
}
else if(S[i]=='o') {
T+='O';
i+=1;
}
else if(S[i]=='r') {
T+='R';
i+=6;
}
}
C=&T[0];
_P("%.12lf\n",floor(expression()*100));
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
kmjp