Submission #1495255
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define oo 1000000
const ll mod = 1e9 + 7;
void ff()
{
std::ios_base::sync_with_stdio(0);
cin.tie(NULL); cout.tie(NULL);
}
//#pragma warning (disable : 4996)
void in_out_txt()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
int main()
{
ff();
//in_out_txt()
string str;
cin >> str;
int c1 = 0, c2 = 0, z = 0, co = 0;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == 'S')
c1++;
else
c1--;
if (c1 < 0)
co++, c1 = 0;
/*if (str[i] == 'S' && z == 0)
c1++;
else if (str[i] == 'T')
c2++, z = 1;
else if (str[i] == 'S' && z == 1)
{
if (c1 >= c2)
c2 = 0, c1 -= c2;
else
co += c2 - c1, c2 = c1 = 0;
z = 0;
i--;
}*/
}
cout << co * 2 << endl;
//system("pause");
return 0;
}
Submission Info
Submission Time |
|
Task |
A - STring |
User |
george_samuel |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1350 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
720 KB |
Compile Error
./Main.cpp: In function ‘void in_out_txt()’:
./Main.cpp:39:34: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("input.txt", "r", stdin);
^
./Main.cpp:40:36: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("output.txt", "w", stdout);
^
Judge Result
Set Name |
Sample |
Subtask1 |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
100 / 100 |
Status |
|
|
|
Set Name |
Test Cases |
Sample |
example0, example1, example2 |
Subtask1 |
example0, example1, example2, sub_corner0, sub_corner1, sub_corner2, sub_rand0, handmade0, handmade1 |
All |
corner0, corner1, corner2, example0, example1, example2, handmade0, handmade1, maxrand0, sub_corner0, sub_corner1, sub_corner2, sub_rand0 |
Case Name |
Status |
Exec Time |
Memory |
corner0 |
AC |
2 ms |
720 KB |
corner1 |
AC |
2 ms |
720 KB |
corner2 |
AC |
2 ms |
720 KB |
example0 |
AC |
1 ms |
256 KB |
example1 |
AC |
1 ms |
256 KB |
example2 |
AC |
1 ms |
256 KB |
handmade0 |
AC |
1 ms |
256 KB |
handmade1 |
AC |
1 ms |
256 KB |
maxrand0 |
AC |
3 ms |
720 KB |
sub_corner0 |
AC |
1 ms |
256 KB |
sub_corner1 |
AC |
1 ms |
256 KB |
sub_corner2 |
AC |
1 ms |
256 KB |
sub_rand0 |
AC |
1 ms |
256 KB |