QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397904#69. LampsRafi220 1ms7940kbC++141.2kb2024-04-24 19:33:152024-04-24 19:33:15

Judging History

你现在查看的是最新测评结果

  • [2024-04-24 19:33:15]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:7940kb
  • [2024-04-24 19:33:15]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;

const int N=1000007;

int DP[N][2];
int id[N];
bool is[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    a='#'+a,b='#'+b;
    int it=0;
    for(int i=1;i<=n;i++)
    {
        if(b[i]!=b[i-1]) it++;
        id[i]=it;
        if(a[i]!=b[i]) is[i]=1;
    }
    DP[0][1]=inf;
    for(int i=1;i<=n;i++)
    {
        DP[i][0]=inf,DP[i][1]=inf;
        if(!is[i])
        {
            DP[i][0]=min(DP[i-1][0],DP[i-1][1]);
        }
        else
        {
            DP[i][1]=min(DP[i-1][0]+1,DP[i-1][1]);
        }
        for(int j=0;j<i;j++)
        {
            int L=(id[i]-id[j+1]+1)/2+1;
            DP[i][0]=min(DP[i][0],DP[j][0]+L);
            DP[i][1]=min(DP[i][1],DP[j][1]+L);
        }
    }
    cout<<min(DP[n][0],DP[n][1]);
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 1ms
memory: 5676kb

input:

1
1
0

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5552kb

input:

1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5676kb

input:

2
10
01

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5676kb

input:

2
01
10

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 1ms
memory: 5840kb

input:

2
11
00

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 1ms
memory: 5672kb

input:

2
11
10

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 1ms
memory: 5668kb

input:

2
11
01

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 1ms
memory: 7720kb

input:

18
000000000000000000
101010101010101010

output:

9

result:

ok single line: '9'

Test #9:

score: 0
Accepted
time: 1ms
memory: 5676kb

input:

18
111111111111111111
010101010101010101

output:

9

result:

ok single line: '9'

Test #10:

score: 0
Accepted
time: 0ms
memory: 7912kb

input:

17
11111111111111111
10101010101010101

output:

8

result:

ok single line: '8'

Test #11:

score: 0
Accepted
time: 0ms
memory: 7712kb

input:

17
00000000000000000
01010101010101010

output:

8

result:

ok single line: '8'

Test #12:

score: 0
Accepted
time: 0ms
memory: 7652kb

input:

18
110111100010101111
010111100011100000

output:

3

result:

ok single line: '3'

Test #13:

score: 0
Accepted
time: 0ms
memory: 7876kb

input:

17
10110110110110101
01011100100110000

output:

4

result:

ok single line: '4'

Test #14:

score: 0
Accepted
time: 1ms
memory: 7656kb

input:

18
000000110001001000
111111001011011100

output:

3

result:

ok single line: '3'

Test #15:

score: 0
Accepted
time: 1ms
memory: 7716kb

input:

17
11011010101011111
10011000100000101

output:

4

result:

ok single line: '4'

Test #16:

score: 0
Accepted
time: 1ms
memory: 7692kb

input:

18
011011101011011000
001010011011110001

output:

4

result:

ok single line: '4'

Test #17:

score: 0
Accepted
time: 1ms
memory: 7756kb

input:

17
10111101010001010
00111001111010010

output:

4

result:

ok single line: '4'

Test #18:

score: 0
Accepted
time: 0ms
memory: 5672kb

input:

18
100110111111001010
100000001101000010

output:

3

result:

ok single line: '3'

Test #19:

score: 0
Accepted
time: 1ms
memory: 5604kb

input:

17
00101111101000011
00111001111110001

output:

3

result:

ok single line: '3'

Test #20:

score: 0
Accepted
time: 0ms
memory: 7916kb

input:

18
001010100000100100
000100110011100110

output:

4

result:

ok single line: '4'

Test #21:

score: 0
Accepted
time: 1ms
memory: 5556kb

input:

17
11101100011001011
11101110111111111

output:

2

result:

ok single line: '2'

Test #22:

score: 0
Accepted
time: 1ms
memory: 5612kb

input:

18
010101110011000110
011001110000001110

output:

3

result:

ok single line: '3'

Test #23:

score: 0
Accepted
time: 0ms
memory: 5912kb

input:

17
10010100000010010
10010111101001000

output:

4

result:

ok single line: '4'

Test #24:

score: 0
Accepted
time: 1ms
memory: 5924kb

input:

18
001111100001101100
001111001111111100

output:

2

result:

ok single line: '2'

Test #25:

score: 0
Accepted
time: 1ms
memory: 7912kb

input:

17
10011011100011110
10000000011100010

output:

2

result:

ok single line: '2'

Test #26:

score: -6
Wrong Answer
time: 1ms
memory: 7940kb

input:

18
010100101101110100
111000010010101001

output:

5

result:

wrong answer 1st lines differ - expected: '4', found: '5'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #59:

score: 4
Accepted
time: 0ms
memory: 5836kb

input:

1
0
0

output:

0

result:

ok single line: '0'

Test #60:

score: 0
Accepted
time: 1ms
memory: 7716kb

input:

1
0
1

output:

1

result:

ok single line: '1'

Test #61:

score: 0
Accepted
time: 0ms
memory: 5840kb

input:

2
00
00

output:

0

result:

ok single line: '0'

Test #62:

score: 0
Accepted
time: 0ms
memory: 7652kb

input:

2
00
10

output:

1

result:

ok single line: '1'

Test #63:

score: 0
Accepted
time: 1ms
memory: 7716kb

input:

2
00
01

output:

1

result:

ok single line: '1'

Test #64:

score: 0
Accepted
time: 0ms
memory: 5676kb

input:

2
00
11

output:

1

result:

ok single line: '1'

Test #65:

score: -4
Time Limit Exceeded

input:

1000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%