QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397925 | #69. Lamps | Rafi22 | 0 | 1ms | 3864kb | C++14 | 1.5kb | 2024-04-24 20:03:43 | 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;
}
詳細信息
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%