Submission #480835

# Submission time Handle Problem Language Result Execution time Memory
480835 2021-10-18T10:22:16 Z Karabasan Election (BOI18_election) C++17
28 / 100
3000 ms 940 KB
#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")

int n,t,m;
int pre[500005];
void solve()
{
    string AAA;
    string s="G";
    cin>>n;
    cin>>AAA;
    s+=AAA;
    int q;
    scanf("%d",&q);
    while(q--)
    {
        string u=s;
        int a,b;
        cin>>a>>b;
        int c=0;
        int t=0;
        int mx=0;
        for(int i=a;i<=b;i++)
        {
            if(u[i]=='T')
                c++;
            else c--;
            if(c>0)
                {
                    u[i]='U';
                    c=0;
                    mx++;
                }

        }
        int mx2=0;
        for(int i=b;i>=a;i--)
        {
            if(u[i]=='T')
                t++;
            else if(u[i]=='C')
                t--;
                mx2=max(mx2,t);
        }
        mx+=mx2;
        cout<<mx<<endl;

    }
}
int main()
{
   // scanf("%d",&t);
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Compilation message

election.cpp: In function 'void solve()':
election.cpp:46:18: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   46 |             else if(u[i]=='C')
      |                  ^~
election.cpp:48:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   48 |                 mx2=max(mx2,t);
      |                 ^~~
election.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 204 KB Output is correct
2 Correct 21 ms 336 KB Output is correct
3 Correct 20 ms 332 KB Output is correct
4 Correct 21 ms 332 KB Output is correct
5 Correct 14 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 204 KB Output is correct
2 Correct 21 ms 336 KB Output is correct
3 Correct 20 ms 332 KB Output is correct
4 Correct 21 ms 332 KB Output is correct
5 Correct 14 ms 332 KB Output is correct
6 Execution timed out 3057 ms 940 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 204 KB Output is correct
2 Correct 21 ms 336 KB Output is correct
3 Correct 20 ms 332 KB Output is correct
4 Correct 21 ms 332 KB Output is correct
5 Correct 14 ms 332 KB Output is correct
6 Execution timed out 3057 ms 940 KB Time limit exceeded
7 Halted 0 ms 0 KB -