Submission #480835

#TimeUsernameProblemLanguageResultExecution timeMemory
480835KarabasanElection (BOI18_election)C++17
28 / 100
3057 ms940 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...