QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207721 | #3016. Flashing Fluorescents | rbjwnb | WA | 0ms | 3844kb | C++14 | 1.2kb | 2023-10-08 19:25:51 | 2023-10-08 19:25:51 |
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 out(ll x) {
for(int i = 0; i < s.size(); i ++) cout << (x >> i & 1) ;
}
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;
vector<int> v(s.size(), 0);
for(int i = 0; i < s.size(); i ++) v[i] += (1 << i);
int j = 0;
while(true) {
if(dp[pos]) {
cout << ans << endl;
return ;
}
// for(auto x : v) {
// out(x);
// cout << " ";
// }
// cout << endl;
ans ++;
vector<bool> t((1 << s.size()), false);
for(auto x : v) {
for(int i = 0; i < (1 << s.size()); i ++)
if(dp[(i ^ x)]) t[i] = true;
}
for(int i = 0; i < (1 << s.size()); i ++) dp[i] = t[i];
j ++;
for(int i = 0; i < s.size(); i ++)
if(i - j >= 0) v[i] += (1 << (i - j));
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while(t --) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
1101
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
000
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
1
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
00
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
01
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
10
output:
1
result:
ok 1 number(s): "1"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
11
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
000
output:
2
result:
ok 1 number(s): "2"
Test #11:
score: -100
Wrong Answer
time: 0ms
memory: 3640kb
input:
001
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'