Submission #1498804


Source Code Expand

#include <cstdio>
#include <cstring>

using namespace std;

int prv[200010];
char str[200010];

int main ()
{
    fgets (str + 1, 200010, stdin);

    int n = strlen (str + 1) - 1;
    for (int i = 1; i <= n; ++i)
        prv[i] = i - 1;

    int lg = n;
    for (int i = 1; i <= n; ++i)
    {
        for (; i <= n && str[i] == 'T' && str[prv[i]] == 'S';)
        {
            lg -= 2;
            prv[i + 1] = prv[prv[i]];
            ++i;
        }
    }

    printf ("%d\n", lg);

    return 0;
}

Submission Info

Submission Time
Task A - STring
User Theodor1000
Language C++14 (GCC 5.4.1)
Score 300
Code Size 533 Byte
Status AC
Exec Time 2 ms
Memory 1152 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:35: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     fgets (str + 1, 200010, stdin);
                                   ^
In file included from /usr/include/stdio.h:937:0,
                 from /usr/include/c++/5/cstdio:42,
                 from ./Main.cpp:1:
In function ‘char* fgets(char*, int, FILE*)’,
    inlined from ‘int main()’ at ./Main.cpp:11:35:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:261:58: warning: call to ‘__fgets_chk_warn’ declared with attribute warning: fgets called with bigger size than length of destination buffer
  return __fgets_chk_warn (__s, __bos (__s), __n, __stream);
                                                          ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 3
AC × 9
AC × 13
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 1 ms 1152 KB
corner1 AC 1 ms 1152 KB
corner2 AC 1 ms 1152 KB
example0 AC 1 ms 128 KB
example1 AC 1 ms 128 KB
example2 AC 1 ms 128 KB
handmade0 AC 1 ms 128 KB
handmade1 AC 1 ms 128 KB
maxrand0 AC 2 ms 1152 KB
sub_corner0 AC 1 ms 128 KB
sub_corner1 AC 1 ms 128 KB
sub_corner2 AC 1 ms 128 KB
sub_rand0 AC 1 ms 128 KB