QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#26519#3016. Flashing FluorescentsHakujitsuWA 3ms3708kbC++1.3kb2022-04-07 16:19:012022-04-29 03:53:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-29 03:53:58]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3708kb
  • [2022-04-07 16:19:01]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}
#ifndef ONLINE_JUDGE
    #define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 42
#endif

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int target = 0;
    for (int i = 0; i < n; i += 1) {
        target = target * 2 + (s[i] == '0');
    }
    vector<int> dp(1 << n);
    dp[0] = 1;
    int res = 1e9;
    int o = 0;
    for (; !dp[target]; o += 1) {
        auto new_dp = dp;
        for (int mask = 0; mask < (1 << n); mask += 1) {
            if(dp[mask] == 0) continue;
            int new_mask = mask;
            
            for (int i = 0; i <= o; i += 1) {
                new_mask ^= 1 << i;    
            }
            for (int i = 0; i + o < n; i += 1) {
                new_dp[new_mask] = max(new_dp[new_mask], dp[mask]);
                new_mask ^= 1 << i;
                new_mask ^= 1 << i + o + 1;
            }
        }
        swap(dp, new_dp);
    }
    cout << o << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3556kb

input:

1101

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 3ms
memory: 3532kb

input:

000

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

0

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

00

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

01

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

10

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

11

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

000

output:

2

result:

ok 1 number(s): "2"

Test #11:

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

input:

001

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: -100
Wrong Answer
time: 1ms
memory: 3628kb

input:

010

output:

3

result:

wrong answer 1st numbers differ - expected: '2', found: '3'