제출 #1216875

#제출 시각아이디문제언어결과실행 시간메모리
1216875moondarksideMiners (IOI07_miners)C++20
100 / 100
785 ms115556 KiB
#include<bits/stdc++.h> using namespace std; string S; int n; int transformA[]={0,1,1,2,1,2,2,3}; unordered_map<int,int> Best; int getMax(char a,char b,int pos){ if(S[pos]=='\0'){ return 0; } int index=(a<<6|b)*n+pos; if(Best[index]!=0){ return Best[index]; } char current; switch(S[pos]){ case 'M': current=1; break; case 'B': current=2; break; case 'F': current=4; break; } int vA=getMax(a>>3 | current<<3|current,b,pos+1)+transformA[(a|current)&7]; int vB=getMax(a,b>>3 | current<<3|current,pos+1)+transformA[(b|current)&7]; Best[index]=max(vA,vB); return max(vA,vB); } int main() { cin>>n>>S; cout<<getMax(0,0,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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...