QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397928#69. LampsRafi220 1ms3864kbC++141.9kb2024-04-24 20:09:242024-04-24 20:09:25

Judging History

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

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

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;

int odw[(1<<18)];

int n;

int cnt(vector<int>V)
{
    int ans=0;
    for(int i=0;i<n;i++) ans+=(1<<i)*V[i];
    return ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    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[cnt(A)]=1;
    deque<int>Q;
    Q.pb(cnt(A));
    int it=0;
    while(sz(Q)>0)
    {
        int v=Q[0];
        Q.pop_front();
        vector<int>V;
        for(int i=0;i<n;i++)
        {
            if(v&(1<<i)) V.pb(1);
            else V.pb(0);
        }
        it++;
        //if(it%100==0) cout<<it<<endl;
        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;
                int t=cnt(X);
                if(!odw[t])
                {
                    odw[t]=odw[v]+1;
                    Q.pb(t);
                }
                for(int k=i;k<=j;k++) X[k]=0;
                t=cnt(X);
                if(!odw[t])
                {
                    odw[t]=odw[v]+1;
                    Q.pb(t);
                }
                for(int k=i;k<=j;k++) X[k]=1;
                t=cnt(X);
                if(!odw[t])
                {
                    odw[t]=odw[v]+1;
                    Q.pb(t);
                }
            }
        }
    }
    cout<<odw[cnt(B)]-1;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

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

input:

1
1
0

output:

1

result:

ok single line: '1'

Test #2:

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

input:

1
1
1

output:

0

result:

ok single line: '0'

Test #3:

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

input:

2
10
01

output:

1

result:

ok single line: '1'

Test #4:

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

input:

2
01
10

output:

1

result:

ok single line: '1'

Test #5:

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

input:

2
11
00

output:

1

result:

ok single line: '1'

Test #6:

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

input:

2
11
10

output:

1

result:

ok single line: '1'

Test #7:

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

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
Runtime Error

Test #59:

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

input:

1
0
0

output:

0

result:

ok single line: '0'

Test #60:

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

input:

1
0
1

output:

1

result:

ok single line: '1'

Test #61:

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

input:

2
00
00

output:

0

result:

ok single line: '0'

Test #62:

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

input:

2
00
10

output:

1

result:

ok single line: '1'

Test #63:

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

input:

2
00
01

output:

1

result:

ok single line: '1'

Test #64:

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

input:

2
00
11

output:

1

result:

ok single line: '1'

Test #65:

score: 0
Runtime Error

input:

1000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%