이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///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
{
map<pair<int,int>,int>mp;
for(int i=0;i<arr.sz-1;i++)
mp[{arr[i],arr1[i+1]}]++;
int ans=0;
for(int i=0;i<arr.sz;i++)
{
for(int j=i;j<arr1.sz;j++)
{
int l=arr[i],r=arr1[i];
int l1=arr1[j],r1=arr1[j];
if(l>r)swap(l,r);
if(l1>r1)swap(l1,r1);
ans+=(l>l1&&r>r1);
ans+=(l<l1&&r<r1);
}
}
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();
}
컴파일 시 표준 에러 (stderr) 메시지
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-1;i++)
| ~^~~~~~~~~
monochrome.cpp:45: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]
45 | for(int i=0;i<arr.sz;i++)
| ^
monochrome.cpp:47:26: 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]
47 | for(int j=i;j<arr1.sz;j++)
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |