QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#535720#9229. Juliet Unifies OnesPhantomThreshold#AC ✓0ms3868kbC++201.0kb2024-08-28 13:50:372024-08-28 13:50:37

Judging History

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

  • [2024-08-28 13:50:37]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3868kb
  • [2024-08-28 13:50:37]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ll long long
//#define int long long
using namespace std;
//using namespace __gnu_pbds;
//#define double long double

inline void upd(int &a,const int &b){ if(a==-1 || a>b)a=b; }
const int maxn = 1100;

int n;
string S;

int f[maxn][2][2];

signed main()
{
	/////////////////////////////////////////////////
	//freopen("tmp.in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>S; n=S.length();
	S=' '+S;
	
	memset(f,-1,sizeof f);
	f[0][0][0]=0;
	for(int i=1;i<=n;i++)
	{
		int c=S[i]-'0';
		for(int j=0;j<2;j++) for(int k=0;k<2;k++) if(f[i-1][j][k]!=-1)
		{
			upd(f[i][j][k],f[i-1][j][k]+1);
			if(c==0)
			{
				upd(f[i][j][c],f[i-1][j][k]);
			}
			else //c==1
			{
				if( k==1 || j==0 )
					upd(f[i][1][c],f[i-1][j][k]);
			}
		}
	}
	int ans=-1;
	for(int j=0;j<2;j++) for(int k=0;k<2;k++) if(f[n][j][k]!=-1)
		upd(ans,f[n][j][k]);
	cout<<ans<<endl;
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

00000000100000000000100000011000

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

11000010100100000011101100000001000100000000000000

output:

8

result:

ok 1 number(s): "8"

Test #7:

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

input:

01100100111011110101010110000100001111110001110001

output:

19

result:

ok 1 number(s): "19"

Test #8:

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

input:

1110101111001

output:

3

result:

ok 1 number(s): "3"

Test #9:

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

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

1001

output:

1

result:

ok 1 number(s): "1"

Test #11:

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

input:

11111111111111111111111111111111111111111111111111

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

11111100000000001101010101100011

output:

9

result:

ok 1 number(s): "9"

Test #13:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #14:

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

input:

11011

output:

1

result:

ok 1 number(s): "1"

Test #15:

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

input:

100011011

output:

2

result:

ok 1 number(s): "2"

Test #16:

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

input:

0

output:

0

result:

ok 1 number(s): "0"

Test #17:

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

input:

1010101010011011001101100110011101101011100110110

output:

19

result:

ok 1 number(s): "19"

Test #18:

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

input:

01110100000000111100000011000000000110010001110101

output:

14

result:

ok 1 number(s): "14"

Test #19:

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

input:

01100001000000010000000000010010000100100101001000

output:

9

result:

ok 1 number(s): "9"

Test #20:

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

input:

1101010101010101010101010101010101010101010101011

output:

23

result:

ok 1 number(s): "23"

Extra Test:

score: 0
Extra Test Passed