QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207725#3016. Flashing FluorescentsrbjwnbAC ✓10ms3944kbC++141.2kb2023-10-08 19:29:422023-10-08 19:29:42

Judging History

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

  • [2023-10-08 19:29:42]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:3944kb
  • [2023-10-08 19:29:42]
  • 提交

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: 3672kb

input:

1101

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

000

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

0

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

00

output:

2

result:

ok 1 number(s): "2"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

01

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

10

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

11

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

000

output:

2

result:

ok 1 number(s): "2"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

001

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

010

output:

2

result:

ok 1 number(s): "2"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

011

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

100

output:

2

result:

ok 1 number(s): "2"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

101

output:

1

result:

ok 1 number(s): "1"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

110

output:

1

result:

ok 1 number(s): "1"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

111

output:

0

result:

ok 1 number(s): "0"

Test #18:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

0000

output:

3

result:

ok 1 number(s): "3"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

0001

output:

2

result:

ok 1 number(s): "2"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

0010

output:

2

result:

ok 1 number(s): "2"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

0011

output:

2

result:

ok 1 number(s): "2"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

0100

output:

2

result:

ok 1 number(s): "2"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

0101

output:

3

result:

ok 1 number(s): "3"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

0110

output:

2

result:

ok 1 number(s): "2"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

0111

output:

1

result:

ok 1 number(s): "1"

Test #26:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1000

output:

2

result:

ok 1 number(s): "2"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

1001

output:

2

result:

ok 1 number(s): "2"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

1010

output:

2

result:

ok 1 number(s): "2"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1011

output:

1

result:

ok 1 number(s): "1"

Test #30:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1100

output:

2

result:

ok 1 number(s): "2"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

1101

output:

1

result:

ok 1 number(s): "1"

Test #32:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1110

output:

1

result:

ok 1 number(s): "1"

Test #33:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1111

output:

0

result:

ok 1 number(s): "0"

Test #34:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

00000

output:

3

result:

ok 1 number(s): "3"

Test #35:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

00001

output:

3

result:

ok 1 number(s): "3"

Test #36:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

00010

output:

3

result:

ok 1 number(s): "3"

Test #37:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

00011

output:

2

result:

ok 1 number(s): "2"

Test #38:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

00100

output:

3

result:

ok 1 number(s): "3"

Test #39:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

00101

output:

2

result:

ok 1 number(s): "2"

Test #40:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

00110

output:

2

result:

ok 1 number(s): "2"

Test #41:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

00111

output:

2

result:

ok 1 number(s): "2"

Test #42:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

01000

output:

3

result:

ok 1 number(s): "3"

Test #43:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

01001

output:

2

result:

ok 1 number(s): "2"

Test #44:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

01010

output:

3

result:

ok 1 number(s): "3"

Test #45:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

01011

output:

3

result:

ok 1 number(s): "3"

Test #46:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

01100

output:

2

result:

ok 1 number(s): "2"

Test #47:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

01101

output:

3

result:

ok 1 number(s): "3"

Test #48:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

01110

output:

2

result:

ok 1 number(s): "2"

Test #49:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

01111

output:

1

result:

ok 1 number(s): "1"

Test #50:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

10000

output:

3

result:

ok 1 number(s): "3"

Test #51:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

10001

output:

2

result:

ok 1 number(s): "2"

Test #52:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

10010

output:

2

result:

ok 1 number(s): "2"

Test #53:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

10011

output:

2

result:

ok 1 number(s): "2"

Test #54:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

10100

output:

2

result:

ok 1 number(s): "2"

Test #55:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

10101

output:

3

result:

ok 1 number(s): "3"

Test #56:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

10110

output:

2

result:

ok 1 number(s): "2"

Test #57:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

10111

output:

1

result:

ok 1 number(s): "1"

Test #58:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

11000

output:

2

result:

ok 1 number(s): "2"

Test #59:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

11001

output:

2

result:

ok 1 number(s): "2"

Test #60:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

11010

output:

2

result:

ok 1 number(s): "2"

Test #61:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

11011

output:

1

result:

ok 1 number(s): "1"

Test #62:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

11100

output:

2

result:

ok 1 number(s): "2"

Test #63:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

11101

output:

1

result:

ok 1 number(s): "1"

Test #64:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

11110

output:

1

result:

ok 1 number(s): "1"

Test #65:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

11111

output:

0

result:

ok 1 number(s): "0"

Test #66:

score: 0
Accepted
time: 2ms
memory: 3944kb

input:

1111101111111000

output:

3

result:

ok 1 number(s): "3"

Test #67:

score: 0
Accepted
time: 3ms
memory: 3708kb

input:

1111110000000000

output:

4

result:

ok 1 number(s): "4"

Test #68:

score: 0
Accepted
time: 3ms
memory: 3652kb

input:

1111110000000010

output:

4

result:

ok 1 number(s): "4"

Test #69:

score: 0
Accepted
time: 3ms
memory: 3908kb

input:

1111101101100100

output:

4

result:

ok 1 number(s): "4"

Test #70:

score: 0
Accepted
time: 3ms
memory: 3912kb

input:

1111100010101100

output:

4

result:

ok 1 number(s): "4"

Test #71:

score: 0
Accepted
time: 4ms
memory: 3644kb

input:

1100100010100000

output:

5

result:

ok 1 number(s): "5"

Test #72:

score: 0
Accepted
time: 3ms
memory: 3744kb

input:

1011001000010001

output:

4

result:

ok 1 number(s): "4"

Test #73:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

1111111111111111

output:

0

result:

ok 1 number(s): "0"

Test #74:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

1011111111111111

output:

1

result:

ok 1 number(s): "1"

Test #75:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

1011111111000111

output:

3

result:

ok 1 number(s): "3"

Test #76:

score: 0
Accepted
time: 5ms
memory: 3908kb

input:

0000000000000000

output:

6

result:

ok 1 number(s): "6"

Test #77:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

1111111111101010

output:

3

result:

ok 1 number(s): "3"

Test #78:

score: 0
Accepted
time: 3ms
memory: 3600kb

input:

1111111101110101

output:

4

result:

ok 1 number(s): "4"

Test #79:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

1111111100110000

output:

3

result:

ok 1 number(s): "3"

Test #80:

score: 0
Accepted
time: 4ms
memory: 3592kb

input:

1111111010101010

output:

5

result:

ok 1 number(s): "5"

Test #81:

score: 0
Accepted
time: 4ms
memory: 3652kb

input:

1111110010101010

output:

5

result:

ok 1 number(s): "5"

Test #82:

score: 0
Accepted
time: 5ms
memory: 3708kb

input:

1111101010101010

output:

6

result:

ok 1 number(s): "6"

Test #83:

score: 0
Accepted
time: 5ms
memory: 3700kb

input:

1111011010101010

output:

6

result:

ok 1 number(s): "6"

Test #84:

score: 0
Accepted
time: 5ms
memory: 3708kb

input:

1111010110101010

output:

6

result:

ok 1 number(s): "6"

Test #85:

score: 0
Accepted
time: 10ms
memory: 3708kb

input:

0010101010101010

output:

8

result:

ok 1 number(s): "8"

Test #86:

score: 0
Accepted
time: 9ms
memory: 3904kb

input:

1010101010101101

output:

8

result:

ok 1 number(s): "8"

Test #87:

score: 0
Accepted
time: 3ms
memory: 3600kb

input:

1010101010111010

output:

7

result:

ok 1 number(s): "7"

Test #88:

score: 0
Accepted
time: 9ms
memory: 3704kb

input:

1011010101010101

output:

8

result:

ok 1 number(s): "8"

Test #89:

score: 0
Accepted
time: 7ms
memory: 3704kb

input:

1110101010101010

output:

7

result:

ok 1 number(s): "7"

Test #90:

score: 0
Accepted
time: 3ms
memory: 3684kb

input:

1010101001010100

output:

7

result:

ok 1 number(s): "7"

Test #91:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

00000010111

output:

4

result:

ok 1 number(s): "4"

Test #92:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

11111111010

output:

2

result:

ok 1 number(s): "2"