Submission #61520

# Submission time Handle Problem Language Result Execution time Memory
61520 2018-07-26T06:41:26 Z 조민규(#2138) Election (BOI18_election) C++11
0 / 100
21 ms 376 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

using namespace std;

char arr[500010];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, q, i, j;
    scanf("%d%s%d", &n, arr + 1, &q);
    for(i = 0; i < q; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);

        int res = 1e9;
        for(int bb = 0; bb < 2; bb++)
        {
            int c = 0;
            int mx = 0;
            for(j = l; j <= r; j++)
            {
                if(arr[j] == 'T')
                    c++;
                else
                    c--;

                mx = max(mx, c);
            }

            int t = 0;
            for(j = l; j <= r && t < mx; j++)
                if(arr[j] == 'T')
                    t++;
            int x = j;

            c = 0;
            int mx2 = 0;
            for(j = r; j >= x; j--)
            {
                if(arr[j] == 'T')
                    c++;
                else
                    c--;

                mx2 = max(mx2, c);
            }

            res = min(res, mx + mx2);
            reverse(arr + l, arr + r + 1);
        }
        printf("%d\n", res);
    }
    return 0;
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%s%d", &n, arr + 1, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
election.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &l, &r);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -