Submission #411408

#TimeUsernameProblemLanguageResultExecution timeMemory
411408iulia2100Monochrome Points (JOI20_monochrome)C++14
0 / 100
1 ms332 KiB
#include <iostream> using namespace std; const int N = 2e5 + 5; int n; int alb[N], neg[N], al, ng; pair <int, int> muchie[N]; //bool idk4(int x, int a, int b) { // if (a < b) // swap(a, b); // if (idk5() && x < b) // return true; // return false; //} int intersectie(int i,int j){ int a=muchie[i].first; int b=muchie[i].second; int c=muchie[j].first; int d=muchie[j].second; if(a<b) swap(a,b); if((a>c and c>b) and (a>d and d>b)) return false; if((a<d or d<b) and (a<c or c<b)) return false; return 1; // if (idk4(a1, a2, b2) == idk4(b1, a2, b2)) // return 0; // return 1; } int idk2(int a){ if(a<=n) return a; a-=n; return a; } int idk(int x) { for(int i=1;i<=n;i++){ muchie[i]=make_pair(alb[i],neg[idk2(i+x-1)]); } int cnt = 0; for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ cnt+=intersectie(i,j); } } // cout<<cnt<<"\n"; return cnt; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; char c; int a, ans = 0; for (int i = 1; i <= n + n; ++i) { cin >> c; a = (c == 'B'); if(a==0){ alb[++al]=i; } else { neg[++ng] = i; } } for (int i = max(1, n / 2 - 1); i <= min(n / 2 + 1, n); ++i) { ans = max(ans, idk(i)); } 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...