Submission #386168

# Submission time Handle Problem Language Result Execution time Memory
386168 2021-04-05T21:53:55 Z fadi57 Lamps (JOI19_lamps) C++14
0 / 100
1000 ms 129624 KB
#include<bits/stdc++.h>
using namespace std;
const int mx=1e5+10;
typedef long long ll;
const int inf=1e9+3e5;
int n;string a,b;
int solve(int i){

if(i==n){return 0;}
int ret=inf;
ret=solve(i+1)+(a[i]!=b[i]);

int togle=0;int turn_on=0;int turn_of=0;
for(int j=i;j<n;j++){
    togle+=(a[j]==b[j]);
    turn_on+=(b[j]=='0');
    turn_of+=(b[j]=='1');
if(j>i){
    ret=min(ret,solve(j+1)+min(min(togle,turn_on),turn_of)+1);}
}
return ret;

}

int main(){
 cin>>n>>a>>b;
 cout<<solve(0);

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Incorrect 2 ms 364 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Incorrect 2 ms 364 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Execution timed out 1096 ms 129624 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Incorrect 2 ms 364 KB Output isn't correct
14 Halted 0 ms 0 KB -