模拟

首先可以求出 0 和 1 的个数

之后按照01 10 的个数贪心安排

细节太多 错的都要哭了

#include<bits/stdc++.h>
using namespace std; int main(){
int a,b,c,d;
while(~scanf("%d %d %d %d",&a,&b,&c,&d)) {
int suc = 1; int t1,t2;
t1 = sqrt(2*a); t2 = sqrt(2*d);
t1 ++; t2 ++;
if(t1*(t1-1) != 2*a || t2*(t2-1) != 2*d) suc = 0; if(d == 0) {
if(!suc) printf("Impossible\n");
else if(b == 0 && c == 0) {
for(int i = 0; i < t1; ++i) printf("0"); printf("\n");
}else if(b+c == t1) {
if(t1 == 1) {
if(b) printf("01\n");
else printf("10\n");
continue;
}
int cc = 0;
if(cc == b) printf("1");
for(int i = 0; i < t1; ++i) {
printf("0");
cc ++;
if(cc == b) printf("1");
} printf("\n");
}
else printf("Impossible\n");
continue;
}else if(a == 0) {
if(!suc) printf("Impossible\n");
else if(b == 0 && c == 0) {
for(int i = 0; i < t2; ++i) printf("1"); printf("\n");
}else if(b+c == t2) {
int cc = 0;
if(cc == c) printf("0");
for(int i = 0; i < t2; ++i) {
printf("1"); cc ++;
if(cc == c) printf("0");
} printf("\n");
}
else printf("Impossible\n");
continue;
} if(b+c != t1*t2) suc = 0;
int num1 = 0, pos1 = 0;
num1 = c/t1; pos1 = c%t1;
int all = num1 + (pos1 > 0);
if(all > t2) suc = 0; if(suc) {
for(int i = 0; i < num1; ++i) printf("1");
int cc = t1;
for(int i = 0; i < t1; ++i) {
cc --;
printf("0");
if(cc == pos1 && cc != 0) printf("1");
}
for(int i = 0; i < t2-all; ++i) printf("1"); printf("\n");
}
else printf("Impossible\n");
}
return 0;
}

CF AIM Tech Round 3 (Div. 2) D - Recover the String的更多相关文章

  1. AIM Tech Round 3 (Div. 2)D. Recover the String(贪心+字符串)

    D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. AIM Tech Round 3 (Div. 1) B. Recover the String 构造

    B. Recover the String 题目连接: http://www.codeforces.com/contest/708/problem/B Description For each str ...

  3. codeforce AIM tech Round 4 div 2 B rectangles

    2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test ...

  4. 【AIM Tech Round 4 (Div. 2) D Prob】

    ·题目:D. Interactive LowerBound ·英文题,述大意:       有一个长度为n(n<=50000)的单链表,里面的元素是递增的.链表存储在一个数组里面,给出长度n.表 ...

  5. AIM Tech Round 3 (Div. 2)

    #include <iostream> using namespace std; ]; int main() { int n, b, d; cin >> n >> ...

  6. AIM Tech Round 3 (Div. 2) A B C D

    虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场 ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被h ...

  7. AIM Tech Round 3 (Div. 2) B

    Description Vasya takes part in the orienteering competition. There are n checkpoints located along ...

  8. AIM Tech Round 3 (Div. 2) A

    Description Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Ko ...

  9. AIM Tech Round 3 (Div. 2) (B C D E) (codeforces 709B 709C 709D 709E)

    rating又掉下去了.好不容易蓝了.... A..没读懂题,wa了好几次,明天问队友补上... B. Checkpoints 题意:一条直线上n个点x1,x2...xn,现在在位置a,求要经过任意n ...

随机推荐

  1. 剑指offer试题(PHP篇二)

    6.旋转数组的最小数字 题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转. 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素. 例如数组{3,4,5,1,2}为{1 ...

  2. 我的前端故事----来聊聊怎么写react-native上的样式吧

    我遇到了什么问题? 不久之前我重构了一个古老的项目,总结了一些js方面的想法,不过对于一个前端项目而言不仅仅只由js组成的嘛,上学的时候老师和我说HTML+CSS+JS对应的是页面的骨架.皮肤和肌肉. ...

  3. php+redis 学习 一 连接

    <?php header('content-type:text/html;chaeset=utf-8'); $redis = new Redis(); $redis->connect('1 ...

  4. LeetCode - 657. Judge Route Circle

    Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot m ...

  5. a:hover 等伪类选择器

    a.random:hover{ color:#64FFDA; font-size:120%; }   //选择的是class="random"的<a>标签.   a#s ...

  6. 模板方法模式和JDBCTemplate(一)

    本篇博客的目录: 一:模板方法模式介绍 二:模板方法模式的简单实现 三:总结 一:模板方法模式的介绍 1.1:模板方法模式的定义 定义:一个操作中的算法的骨架,而将一些步骤延迟到子类中.Templat ...

  7. centos/linux下的使得maven/tomcat能在普通用户是使用

    以下操作#代表在root用户下使用 $表示在普通用户下使用 1.创建新用户 # useradd lonecloud 2.设置该用户的密码 # passwd lonecloud 3.因为昨天将tomca ...

  8. org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/lonecloud/tomcat/apache-tomcat-7.0.70 2/webapps/myproject/WEB-INF/classes/cn/lone

    解决这个报错的解决办法: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidat ...

  9. cmd命令报4048错误

    解决方法: win10系统:快捷键win+x,找到命令提示符(管理员),打开再下载相应的依赖包. win7/8:打开开始,输入命令提示符,找到管理员权限的命令提示符,打开再下载相应的依赖包. 提示:如 ...

  10. 《精通android网络开发》--HTTP数据通信

    No1: 例如:http://www.*****.com/china/index.htm 1)http:// 代表超文本传送协议,通知*****.com服务器显示web页,通常不用输入 2)www 代 ...