-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathACPC10C.cpp
105 lines (81 loc) · 3.6 KB
/
ACPC10C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include<iostream>
#include<stdio.h>
#include<string>
#include<stack>
using namespace std;
int main()
{
string s1="";
int k=1;
while(true)
{
cin>>s1;
stack<int> s;
if(s1=="()")
break;
int count=0,count2=-1;
bool z,x=0;
for(int i=0;i<s1.length();i++)
{
if(s1[i]=='(')
{
count++;
s.push(2);
}
else if(s1[i]=='T')
s.push(1);
else if(s1[i]=='F')
s.push(0);
else if(s1[i]==')')
{
if(count%2==0)
{
if(x==0)
{
z=0;
x=1;
}
while(s.top()!=2)
{
z=z+s.top();
s.pop();
}
}
else if(count%2)
{
if(x==0)
{
z=1;
x=1;
}
int y=s.top();
while(y!=2)
{
z=z*y;
s.pop();
y=s.top();
}
}
if(count2==count)
{
if(z)
z=0;
else
z=1;
}
count--;
count2=count;
s.pop();
s.push(z);
x=0;
}
}
if(z==0)
cout<<k<<". false"<<endl;
else
cout<<k<<". true"<<endl;
k++;
}
system ("pause");
return 0;
}