Submission #516558

#TimeUsernameProblemLanguageResultExecution timeMemory
516558leinad2Monochrome Points (JOI20_monochrome)C++17
25 / 100
2070 ms332 KiB
#include<bits/stdc++.h> using namespace std; int n, i, j, k, a, b, ans; char S[400010]; vector<int>A, B; main() { scanf("%d", &n); scanf("%s", &S); for(i=0;i<2*n;i++) { if(S[i]=='B')A.push_back(i+1); else B.push_back(i+1); } for(i=0;i<n;i++) { vector<pair<int, int> >V; for(j=i;j<n;j++)V.push_back({A[j-i], B[j]}); for(j=0;j<i;j++)V.push_back({A[j+n-i], B[j]}); for(auto &p:V)if(p.first>p.second)swap(p.first, p.second); int res=0; for(j=0;j<V.size();j++)for(k=j+1;k<V.size();k++) { if((V[j].first<V[k].first&&V[k].first<V[j].second&&V[j].second<V[k].second)||(V[k].first<V[j].first&&V[j].first<V[k].second&&V[k].second<V[j].second))res++; } ans=max(ans, res); } cout<<ans; }

Compilation message (stderr)

monochrome.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
monochrome.cpp: In function 'int main()':
monochrome.cpp:9:13: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[400010]' [-Wformat=]
    9 |     scanf("%s", &S);
      |            ~^   ~~
      |             |   |
      |             |   char (*)[400010]
      |             char*
monochrome.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(j=0;j<V.size();j++)for(k=j+1;k<V.size();k++)
      |                 ~^~~~~~~~~
monochrome.cpp:22:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(j=0;j<V.size();j++)for(k=j+1;k<V.size();k++)
      |                                          ~^~~~~~~~~
monochrome.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
monochrome.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%s", &S);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...