Submission #849021

#TimeUsernameProblemLanguageResultExecution timeMemory
849021oscar1fMonochrome Points (JOI20_monochrome)C++17
25 / 100
2037 ms600 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int nbVal; vector<int> initType; string valDeb; int verif(int bla1,int noir1,int bla2,int noir2) { if (bla1>bla2) { return verif(bla2,noir2,bla1,noir1); } if (bla1>noir1) { return verif(noir1,bla1,noir2,bla2); } if (bla2>bla1 and bla2<noir1) { if (noir2>noir1 or noir2<bla1) { return 1; } else { return 0; } } else { if (noir2>bla1 and noir2<noir1) { return 1; } else { return 0; } } } int compt(vector<int> listeBla,vector<int> listeNoir) { int nbInter=0; for (int i=0;i<nbVal;i++) { for (int j=i+1;j<nbVal;j++) { nbInter+=verif(listeBla[i],listeNoir[i],listeBla[j],listeNoir[j]); } } return nbInter; } int calc(vector<int> typeSom) { int rep=0; vector<int> listeBla,listeNoir; for (int i=0;i<2*nbVal;i++) { if (typeSom[i]==0) { listeBla.push_back(i); } else { listeNoir.push_back(i); } } vector<int> ordreNoir; for (int i=0;i<nbVal;i++) { ordreNoir.clear(); for (int j=0;j<nbVal;j++) { ordreNoir.push_back(listeNoir[(i+j)%nbVal]); } rep=max(rep,compt(listeBla,ordreNoir)); } return rep; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>nbVal; cin>>valDeb; for (int i=0;i<2*nbVal;i++) { if (valDeb[i]=='W') { initType.push_back(0); } else { initType.push_back(1); } } cout<<calc(initType)<<endl; 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...