第20届纪念款-牛客周赛 Round 20 B.C简单构造

B

第20届纪念款-牛客周赛 Round 20 B.C简单构造_第1张图片

答案要么是0  要么是1

所以你全部填0或者要么填1然后算就好了

#include
using namespace std;
using ll = long long;
const int N = 1e5+10;
int n;



void solve()
{
   //全0 全1?
   string str;cin>>str;
   n = str.size();
   string str1 = str;
   int ans1 = 0;
   int tem = 0;
   for(int i=0;i

C

第20届纪念款-牛客周赛 Round 20 B.C简单构造_第2张图片

你先算出每一段的起码的长度就好了

t对相邻 故需要连续的1 t+1个

剩余的1为  k-t-1 且需要这么多0

再多的数字的话你直接填上 0 就好了

#include
using namespace std;
using ll = long long;
const int N = 1e5+10;

int n,k,t;
void solve()
{

 //t+1个连续的1
 //k-t-1剩余的1 至少k-t-1个0
 //n>上面
 
	cin>>n>>k>>t;
	int s11 = t+1;
	int s1 = k-t-1;
	int s0 = k-t-1;
 
	 
	 if(n

你可能感兴趣的:(模拟,思维,c语言,蓝桥杯,c++,算法,学习,职场和发展)