# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167375 | L01 | Miners (IOI07_miners) | C++17 | 276 ms | 100960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int tablapd[100005][4][4][4][4],tletras,letras[100005];
char letra;
int costo(int n1,int n2,int n3)
{
if(n1==0 and n2==0)
return 1;
if(n1==0 and n2!=n3)
return 2;
if(n1==0 and n2==n3)
return 1;
if(n2==0 and n1!=n3)
return 2;
if(n2==0 and n1==n3)
return 1;
if(n1==n2 and n2==n3)
return 1;
if((n1==n2 and n1!=n3) or (n1==n3 and n1!=n2) or (n2==n3 and n1!=n2))
return 2;
if(n1!=n2 and n1!=n3 and n2!=n3)
return 3;
}
int main()
{
cin>>tletras;
for(int i=1;i<=tletras;i++)
{
cin>>letra;
if(letra=='M')
letras[i]=1;
if(letra=='B')
letras[i]=2;
if(letra=='F')
letras[i]=3;
}
for(int i=tletras-1;i>=0;i--)
{
for(int a=0;a<=3;a++)
{
for(int b=0;b<=3;b++)
{
for(int c=0;c<=3;c++)
{
for(int d=0;d<=3;d++)
{
int e=letras[i+1];
tablapd[i][a][b][c][d]=max(tablapd[i+1][b][e][c][d]+costo(a,b,e),tablapd[i+1][a][b][d][e]+costo(c,d,e));
}
}
}
}
}
cout<<tablapd[0][0][0][0][0];
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |