QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#26519 | #3016. Flashing Fluorescents | Hakujitsu | WA | 3ms | 3708kb | C++ | 1.3kb | 2022-04-07 16:19:01 | 2022-04-29 03:53:58 |
Judging History
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'