QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#26521#3016. Flashing FluorescentsHakujitsuWA 3ms3712kbC++1.3kb2022-04-07 16:21:432022-04-29 03:54:20

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:54:20]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3712kb
  • [2022-04-07 16:21:43]
  • 提交

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 < n; i += 1) {
                new_dp[new_mask] = max(new_dp[new_mask], dp[mask]);
                new_mask ^= 1 << i;
                if(i + o + 1 < n) new_mask ^= 1 << i + o + 1;
            }
        }
        swap(dp, new_dp);
    }
    cout << o << "\n";
    return 0;
}

詳細信息

Test #1:

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

input:

1101

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

000

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

0

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

00

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

01

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

10

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

11

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

000

output:

2

result:

ok 1 number(s): "2"

Test #11:

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

input:

001

output:

2

result:

ok 1 number(s): "2"

Test #12:

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

input:

010

output:

2

result:

ok 1 number(s): "2"

Test #13:

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

input:

011

output:

1

result:

ok 1 number(s): "1"

Test #14:

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

input:

100

output:

2

result:

ok 1 number(s): "2"

Test #15:

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

input:

101

output:

1

result:

ok 1 number(s): "1"

Test #16:

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

input:

110

output:

1

result:

ok 1 number(s): "1"

Test #17:

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

input:

111

output:

0

result:

ok 1 number(s): "0"

Test #18:

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

input:

0000

output:

3

result:

ok 1 number(s): "3"

Test #19:

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

input:

0001

output:

2

result:

ok 1 number(s): "2"

Test #20:

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

input:

0010

output:

2

result:

ok 1 number(s): "2"

Test #21:

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

input:

0011

output:

2

result:

ok 1 number(s): "2"

Test #22:

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

input:

0100

output:

2

result:

ok 1 number(s): "2"

Test #23:

score: -100
Wrong Answer
time: 2ms
memory: 3632kb

input:

0101

output:

2

result:

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