Submission #516307

#TimeUsernameProblemLanguageResultExecution timeMemory
516307jk410Monochrome Points (JOI20_monochrome)C++17
4 / 100
10 ms332 KiB
#include <bits/stdc++.h> using namespace std; int N,Ans; string S; int A[17]; bool Used[17]; int B[9][2]; bool g(int a,int b,int c,int d){ if (a>b) swap(a,b); if (c>d) swap(c,d); if (a>c){ swap(a,c); swap(b,d); } return c<b&&b<d; } void f(int t){ int w=0; for (int i=1; i<=N*2; i++){ if (!A[i]&&!Used[i]){ w=i; break; } } if (!w){ int tmp=0; for (int i=1; i<=N; i++){ for (int j=i+1; j<=N; j++) tmp+=g(B[i][0],B[i][1],B[j][0],B[j][1]); } Ans=max(Ans,tmp); return; } Used[w]=true; B[t][0]=w; for (int i=1; i<=N*2; i++){ if (A[i]&&!Used[i]){ Used[i]=true; B[t][1]=i; f(t+1); Used[i]=false; } } Used[w]=false; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>N>>S; for (int i=1; i<=N*2; i++) A[i]=(S[i-1]=='B'); f(1); cout<<Ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...