QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397925#69. LampsRafi220 1ms3864kbC++141.5kb2024-04-24 20:03:432024-04-24 20:03:43

Judging History

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

  • [2024-04-24 20:03:43]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3864kb
  • [2024-04-24 20:03:43]
  • 提交

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;

map<vector<int>,int>odw;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    vector<int>A,B;
    for(auto x:a) A.pb(x-'0');
    for(auto x:b) B.pb(x-'0');
    odw[A]=1;
    deque<vector<int>>Q;
    Q.pb(A);
    while(sz(Q)>0)
    {
        vector<int> V=Q[0];
        Q.pop_front();
        for(int i=0;i<n;i++)
        {
            for(int j=i;j<n;j++)
            {
                vector<int>X=V;
                for(int k=i;k<=j;k++) X[k]^=1;
                if(!odw[X])
                {
                    odw[X]=odw[V]+1;
                    Q.pb(X);
                }
                for(int k=i;k<=j;k++) X[k]=0;
                if(!odw[X])
                {
                    odw[X]=odw[V]+1;
                    Q.pb(X);
                }
                for(int k=i;k<=j;k++) X[k]=1;
                if(!odw[X])
                {
                    odw[X]=odw[V]+1;
                    Q.pb(X);
                }
            }
        }
    }
    cout<<odw[B]-1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 6
Accepted
time: 0ms
memory: 3628kb

input:

1
1
0

output:

1

result:

ok single line: '1'

Test #2:

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

input:

1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 0ms
memory: 3620kb

input:

2
10
01

output:

1

result:

ok single line: '1'

Test #4:

score: 6
Accepted
time: 0ms
memory: 3864kb

input:

2
01
10

output:

1

result:

ok single line: '1'

Test #5:

score: 6
Accepted
time: 0ms
memory: 3564kb

input:

2
11
00

output:

1

result:

ok single line: '1'

Test #6:

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

input:

2
11
10

output:

1

result:

ok single line: '1'

Test #7:

score: 6
Accepted
time: 0ms
memory: 3636kb

input:

2
11
01

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Time Limit Exceeded

input:

18
000000000000000000
101010101010101010

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #59:

score: 4
Accepted
time: 1ms
memory: 3596kb

input:

1
0
0

output:

0

result:

ok single line: '0'

Test #60:

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

input:

1
0
1

output:

1

result:

ok single line: '1'

Test #61:

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

input:

2
00
00

output:

0

result:

ok single line: '0'

Test #62:

score: 4
Accepted
time: 1ms
memory: 3856kb

input:

2
00
10

output:

1

result:

ok single line: '1'

Test #63:

score: 4
Accepted
time: 1ms
memory: 3620kb

input:

2
00
01

output:

1

result:

ok single line: '1'

Test #64:

score: 4
Accepted
time: 1ms
memory: 3632kb

input:

2
00
11

output:

1

result:

ok single line: '1'

Test #65:

score: 0
Time Limit Exceeded

input:

1000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%