QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207694#3016. Flashing FluorescentsrbjwnbWA 0ms3732kbC++14927b2023-10-08 19:08:062023-10-08 19:08:07

Judging History

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

  • [2023-10-08 19:08:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2023-10-08 19:08:06]
  • 提交

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;
}

詳細信息

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'