Submission #145386

#TimeUsernameProblemLanguageResultExecution timeMemory
145386MKopchevElection (BOI18_election)C++14
28 / 100
3032 ms1360 KiB
#include <bits/stdc++.h> using namespace std; const int nmax=5e5+42; int n,q; char in[nmax],inp[nmax]; bool out[nmax]; int main() { scanf("%i",&n); scanf("%s",&in); for(int i=1;i<=n;i++) inp[i]=in[i-1]; scanf("%i",&q); int l,r; for(int i=1;i<=q;i++) { scanf("%i%i",&l,&r); for(int j=l;j<=r;j++)out[j]=0; int c=0,removed=0; for(int j=l;j<=r;j++) { if(inp[j]=='C')c++; else { if(c)c--; else out[j]=1,removed++; } } c=0; for(int j=r;j>=l;j--) { if(inp[j]=='C')c++; else if(out[j]==0) { if(c)c--; else out[j]=1,removed++; } } printf("%i\n",removed); } }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:10:19: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[500042]' [-Wformat=]
     scanf("%s",&in);
                ~~~^
election.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
election.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",&in);
     ~~~~~^~~~~~~~~~
election.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&q);
     ~~~~~^~~~~~~~~
election.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&l,&r);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...