QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207694 | #3016. Flashing Fluorescents | rbjwnb | WA | 0ms | 3732kb | C++14 | 927b | 2023-10-08 19:08:06 | 2023-10-08 19:08:07 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 1e6+5, M = 1e6+5;
const int MOD = 998244353, INF = 0x3f3f3f3f;
string s;
bool dp[(1 << 16)];
void solve() {
ll res = 0, t = 1;
cin >> s;
for(int i = s.size() - 1; i >= 0; i --) {
if(s[i] == '1') res += t;
t <<= 1;
}
ll pos = (1 << s.size()) - 1;
dp[res] = true;
ll ans = 0, temp = 0;
while(true) {
if(dp[pos]) {
cout << max(0ll, ans - 1)<< endl;
return ;
}
temp <<= 1;
temp |= 1;
ans ++;
vector<bool> t((1 << s.size()), false);
for(int i = 0; i < (1 << s.size()); i ++) {
if(dp[i] | dp[(i ^ temp)]) t[i] = true;
}
for(int i = 0; i < (1 << s.size()); i ++) dp[i] = t[i];
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while(t --) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
1101
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
000
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
0
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'