Submission #850525

#TimeUsernameProblemLanguageResultExecution timeMemory
850525oscar1fMonochrome Points (JOI20_monochrome)C++17
35 / 100
2028 ms16852 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,temp,mini,maxi; for (int i=0;i<nbVal;i++) { mini=min(listeBla[i],listeNoir[i]); maxi=max(listeBla[i],listeNoir[i]); temp=min(maxi-mini-1,2*nbVal-maxi-1+mini); //cout<<listeBla[i]<<" "<<listeNoir[i]<<" "<<temp<<" "; nbInter+=temp; } return nbInter/2; /*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]); } int temp=compt(listeBla,ordreNoir); //cout<<" = "<<temp<<endl; rep=max(rep,temp); } //cout<<endl; 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...