43 lines
931 B
C++
43 lines
931 B
C++
|
#include <iostream>
|
||
|
#include <stack>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main(int argc, char* argv[])
|
||
|
{
|
||
|
string str_in;
|
||
|
string openers = "([{<";
|
||
|
string closers = ")]}>";
|
||
|
int result = 0;
|
||
|
int scores[4] = {3,57,1197,25137};
|
||
|
|
||
|
while(cin >> str_in)
|
||
|
{
|
||
|
stack<char> parser;
|
||
|
|
||
|
for(unsigned int i = 0; i < str_in.size(); i++)
|
||
|
{
|
||
|
size_t found_pos;
|
||
|
if (openers.find(str_in[i])!=string::npos)
|
||
|
{
|
||
|
parser.push(str_in[i]);
|
||
|
}
|
||
|
else if ((found_pos=closers.find(str_in[i]))!=string::npos)
|
||
|
{
|
||
|
if (parser.top() != openers[found_pos])
|
||
|
{
|
||
|
result += scores[found_pos];
|
||
|
break;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
parser.pop();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
cout << result << endl;
|
||
|
|
||
|
return 0;
|
||
|
}
|