Submission #138131

# Submission time Handle Problem Language Result Execution time Memory
138131 2019-07-29T11:55:21 Z Bodo171 Lamps (JOI19_lamps) C++14
4 / 100
87 ms 4556 KB
#include <iostream>
#include <fstream>
using namespace std;
int dp[2][10];
int cst,i,j,k,n,use,x,y,ans;
string a,b;
bool valid(int x,int y,int mov)
{
    if(mov%3)
        return ((mov%3)-1==y);
    return ((x^y)==mov/3);
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    cin>>a>>b;
    for(i=1;i<6;i++)
        dp[0][i]=(1<<30);
    for(i=0;i<n;i++)
    {
        use=1-use;
        x=a[i]-'0';y=b[i]-'0';
        for(j=0;j<6;j++)
            dp[use][j]=(1<<30);
        for(j=0;j<6;j++)
            if(valid(x,y,j))
             for(k=0;k<6;k++)
        {
            cst=(((j%3)!=(k%3)&&j%3!=0)+((j/3)>(k/3)));
            dp[use][j]=min(dp[use][j],dp[1-use][k]+cst);
        }
    }
    ans=(1<<30);
    for(j=0;j<6;j++)
        ans=min(ans,dp[use][j]);
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 276 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 416 KB Output is correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 276 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 416 KB Output is correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 85 ms 4500 KB Output is correct
8 Correct 85 ms 4552 KB Output is correct
9 Correct 85 ms 4444 KB Output is correct
10 Correct 85 ms 4552 KB Output is correct
11 Correct 87 ms 4440 KB Output is correct
12 Correct 84 ms 4416 KB Output is correct
13 Correct 86 ms 4500 KB Output is correct
14 Correct 85 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 276 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 416 KB Output is correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -