Submission #516558

# Submission time Handle Problem Language Result Execution time Memory
516558 2022-01-21T13:15:35 Z leinad2 Monochrome Points (JOI20_monochrome) C++17
25 / 100
2000 ms 332 KB
#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

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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 296 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 296 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 15 ms 204 KB Output is correct
15 Correct 15 ms 316 KB Output is correct
16 Correct 14 ms 316 KB Output is correct
17 Correct 14 ms 316 KB Output is correct
18 Correct 10 ms 204 KB Output is correct
19 Correct 12 ms 304 KB Output is correct
20 Correct 12 ms 312 KB Output is correct
21 Correct 12 ms 312 KB Output is correct
22 Correct 11 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 10 ms 312 KB Output is correct
25 Correct 14 ms 308 KB Output is correct
26 Correct 12 ms 296 KB Output is correct
27 Correct 13 ms 308 KB Output is correct
28 Correct 15 ms 316 KB Output is correct
29 Correct 11 ms 204 KB Output is correct
30 Correct 11 ms 320 KB Output is correct
31 Correct 18 ms 332 KB Output is correct
32 Correct 17 ms 312 KB Output is correct
33 Correct 16 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 296 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 15 ms 204 KB Output is correct
15 Correct 15 ms 316 KB Output is correct
16 Correct 14 ms 316 KB Output is correct
17 Correct 14 ms 316 KB Output is correct
18 Correct 10 ms 204 KB Output is correct
19 Correct 12 ms 304 KB Output is correct
20 Correct 12 ms 312 KB Output is correct
21 Correct 12 ms 312 KB Output is correct
22 Correct 11 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 10 ms 312 KB Output is correct
25 Correct 14 ms 308 KB Output is correct
26 Correct 12 ms 296 KB Output is correct
27 Correct 13 ms 308 KB Output is correct
28 Correct 15 ms 316 KB Output is correct
29 Correct 11 ms 204 KB Output is correct
30 Correct 11 ms 320 KB Output is correct
31 Correct 18 ms 332 KB Output is correct
32 Correct 17 ms 312 KB Output is correct
33 Correct 16 ms 316 KB Output is correct
34 Execution timed out 2070 ms 332 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 296 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 15 ms 204 KB Output is correct
15 Correct 15 ms 316 KB Output is correct
16 Correct 14 ms 316 KB Output is correct
17 Correct 14 ms 316 KB Output is correct
18 Correct 10 ms 204 KB Output is correct
19 Correct 12 ms 304 KB Output is correct
20 Correct 12 ms 312 KB Output is correct
21 Correct 12 ms 312 KB Output is correct
22 Correct 11 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 10 ms 312 KB Output is correct
25 Correct 14 ms 308 KB Output is correct
26 Correct 12 ms 296 KB Output is correct
27 Correct 13 ms 308 KB Output is correct
28 Correct 15 ms 316 KB Output is correct
29 Correct 11 ms 204 KB Output is correct
30 Correct 11 ms 320 KB Output is correct
31 Correct 18 ms 332 KB Output is correct
32 Correct 17 ms 312 KB Output is correct
33 Correct 16 ms 316 KB Output is correct
34 Execution timed out 2070 ms 332 KB Time limit exceeded
35 Halted 0 ms 0 KB -