QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207721#3016. Flashing FluorescentsrbjwnbWA 0ms3844kbC++141.2kb2023-10-08 19:25:512023-10-08 19:25:51

Judging History

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

  • [2023-10-08 19:25:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2023-10-08 19:25:51]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

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'