Submission #850048

# Submission time Handle Problem Language Result Execution time Memory
850048 2023-09-15T16:50:15 Z Mr_Ph Monochrome Points (JOI20_monochrome) C++14
0 / 100
1 ms 344 KB
///Never gonna give you up.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
const ll mod=(ll)1e9+7;
const ll mod1=998244353;
///the defines :)
//#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
#define int long long
void preprocess() {}
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<int,char>mp;
    vi arr;
        vi arr1;
    int xd=0;
    for(int i=0;i<s.sz;i++)
    {
        if(s[i]=='W')arr.push_back(i+1);
        else arr1.push_back(i+1);
    }
    do
    {
        int ans=0;
        for(int i=0;i<arr.sz;i++)
        {
            for(int j=i+1;j<arr1.sz;j++)
            {
                int l=arr[i],r=arr1[i];
                int l1=arr[j],r1=arr1[j];
                if(l>r)swap(l,r);
                if(l1>r1)swap(l1,r1);
                ans+=1-(((l<r1)&(r>r1))|((l1<r)&(l<l1)));
            }
        }
        xd=max(xd,ans);
       // cout<<"-----------"<<endl;
    }while(next_permutation(all(arr)));
    cout<<xd<<endl;
}
signed main()
{
    // freopen("div7.in","r",stdin);
    //freopen("div7.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    preprocess();
    //bla();
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

Compilation message

monochrome.cpp: In function 'void solve()':
monochrome.cpp:34:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0;i<s.sz;i++)
      |                  ^
monochrome.cpp:42:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int i=0;i<arr.sz;i++)
      |                      ^
monochrome.cpp:44:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(int j=i+1;j<arr1.sz;j++)
      |                            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -