虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场

ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被hack了...做完B想出了D的正解企图绝杀..然而还是失败了..

想了想还是由于自己不够认真吧..手速做完前三题 看着能涨分的名次就不太努力的做D了..中间还水了一下群..浪费了很多时间 导致最后没有能够完成D

A n个数 大于b被抛弃 不然就加入容器 如果容器中的和大于d 清理容器 直接模拟就好

B n个x轴点和初始坐标a 问走完至少n-1个点需要多少时间 可以想到走n-1个点一定是最优的 那么排序之后分别尝试抛弃x[1]和x[n] 输出最小值 当n==1时 直接输出0 因为这个被hack..

C 给出一个字符串 在其中选择一个连续非空子串 使其中的所有字母都-1 求这样操作一下这个字符串能达到的最小字典序 可以想到从前往后每个点的重要程度是依次下降的 寻找到第一个不是a的位置 使其作为子串的起点 再向右寻找直到尾点是a 如果找不到起点 说明全是a 那就把最后一个变为z

D 给出 a00 a01 a10 a11 分别代表 在一个由0 1组成的字符串中 00 01 10 11对的个数 问是否存在这样的字符串 有就输出 否则输出im

可以由a00 和 a11求出0 1 的个数x y 需要注意的是a00为0的时候 x有两个可能值 0 1 所以x与y的组合情况有四种

当我们确定了x和y存在的时候 可以想出 x*y == a01 + a10 在四种情况中如果都不满足 就输出im

当有一个满足的时候 就是说 x个0和y个1一定可以组成满足题意的式子 这时候进行简单的特判 即一个为0的时候 直接输出另外一个

当都不为0的时候 可以将其摆为0..01..101..10..0的形式 先在1的尾部尝试放0 如果a10可以整除 就不用在1中间插0

当把尾部和可能存在的中间的部位插完之后 我们的策略一定是满足a10的 因为式子成立 所以剩下的0全部放在最前 一定是可以成立的

每次进行字符串的输出之后直接return 0 到最后再搞一个输出im出来

虽然比较长 .. 但是大部分都是复制粘贴的..

一个trick即test4 是0 0 0 0 这时候 可能的字符串是存在的 即0或者1 .. 利用上面提到的四种情况是可以得到的..但是自己居然认为这个是错点..写了特判输出im..真傻..

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<stack>
using namespace std;
long long a10,a01,a11,a00;
int main()
{
cin>>a00>>a01>>a10>>a11;
if(a00==0&&a01==0&&a10==0&&a11==0)
{
printf("0\n");
return 0;
}
long long x; /// 0
long long y; /// 1
long long a000=a00*2;
long long a111=a11*2;
long long q= sqrt(a000);
bool ok = true;
bool fin = false;
if((q*(q+1))==a000)
{
x=q+1;
}
else ok=false;
if(ok)
{
long long w= sqrt(a111);
if((w*(w+1))==a111)
{
y=w+1;
}
else ok=false;
if(ok)
{
/// 1 -
if(a000==0)
x=1;
if(a111==0)
y=1; if((x*y)==(a01+a10))
{
if((x+y)>1000000)
{
printf("Impossible\n");
return 0;
}
if(x==0&&y==0)
{
printf("Impossible\n");
return 0;
}
else if(x==0)
{
for(int i=0; i<y; i++)
{
printf("1");
}
printf("\n");
return 0;
}
else if(y==0)
{
for(int i=0; i<x; i++)
{
printf("0");
}
printf("\n");
return 0;
}
/// x y
int aa01=a01;
int aa10=a10;
int cnt =0;
int ss=-1;
while(true)
{
y--;
if(aa01>x)
{
cnt ++;
aa01-=x;
}
else
{
ss=aa01;
aa01=0;
}
if(aa01==0)
break;
}
if(y>=0)
{
if(ss==-1)
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n");
}
else
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=ss; i++)
printf("0");
printf("1");
for(int i=ss; i<x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n"); }
return 0;
}
}
/// 2
if(a000==0)
x=0;
if(a111==0)
y=1; if((x*y)==(a01+a10))
{
if((x+y)>1000000)
{
printf("Impossible\n");
return 0;
}
if(x==0&&y==0)
{
printf("Impossible\n");
return 0;
}
else if(x==0)
{
for(int i=0; i<y; i++)
{
printf("1");
}
printf("\n");
return 0;
}
else if(y==0)
{
for(int i=0; i<x; i++)
{
printf("0");
}
printf("\n");
return 0;
}
int aa01=a01;
int aa10=a10;
int cnt =0;
int ss=-1;
while(true)
{
y--;
if(aa01>x)
{
cnt ++;
aa01-=x;
}
else
{
ss=aa01;
aa01=0;
}
if(aa01==0)
break;
}
if(y>=0)
{
if(ss==-1)
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n");
}
else
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=ss; i++)
printf("0");
printf("1");
for(int i=ss; i<x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n"); }
return 0;
}
}
/// 3
if(a000==0)
x=1;
if(a111==0)
y=0; if((x*y)==(a01+a10))
{
if((x+y)>1000000)
{
printf("Impossible\n");
return 0;
}
if(x==0&&y==0)
{
printf("Impossible\n");
return 0;
}
else if(x==0)
{
for(int i=0; i<y; i++)
{
printf("1");
}
printf("\n");
return 0;
}
else if(y==0)
{
for(int i=0; i<x; i++)
{
printf("0");
}
printf("\n");
return 0;
}
int aa01=a01;
int aa10=a10;
int cnt =0;
int ss=-1;
while(true)
{
y--;
if(aa01>x)
{
cnt ++;
aa01-=x;
}
else
{
ss=aa01;
aa01=0;
}
if(aa01==0)
break;
}
if(y>=0)
{
if(ss==-1)
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n");
}
else
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=ss; i++)
printf("0");
printf("1");
for(int i=ss; i<x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n"); }
return 0;
}
}
/// 4
if(a000==0)
x=0;
if(a111==0)
y=0; if((x*y)==(a01+a10))
{
if((x+y)>1000000)
{
printf("Impossible\n");
return 0;
}
if(x==0&&y==0)
{
printf("Impossible\n");
return 0;
}
else if(x==0)
{
for(int i=0; i<y; i++)
{
printf("1");
}
printf("\n");
return 0;
}
else if(y==0)
{
for(int i=0; i<x; i++)
{
printf("0");
}
printf("\n");
return 0;
}
int aa01=a01;
int aa10=a10;
int cnt =0;
int ss=-1;
while(true)
{
y--;
if(aa01>x)
{
cnt ++;
aa01-=x;
}
else
{
ss=aa01;
aa01=0;
}
if(aa01==0)
break;
}
if(y>=0)
{
if(ss==-1)
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n");
}
else
{
for(int i=1; i<=y; i++)
printf("1");
for(int i=1; i<=ss; i++)
printf("0");
printf("1");
for(int i=ss; i<=x; i++)
printf("0");
for(int i=1; i<=cnt; i++)
printf("1");
printf("\n"); }
return 0;
}
}
printf("Impossible\n");
return 0;
}
else
{
printf("Impossible\n");
}
}
else
{
printf("Impossible\n");
}
}

  

AIM Tech Round 3 (Div. 2) A B C D的更多相关文章

  1. 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 ...

  2. AIM Tech Round 3 (Div. 2)

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

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

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

  4. 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 ...

  5. 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 ...

  6. AIM Tech Round 3 (Div. 2) B 数学+贪心

    http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-1个点所需要的最小路程. 思路:我们知道,如 ...

  7. 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 ...

  8. AIM Tech Round 4 (Div. 2)ABCD

    A. Diversity time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  9. AIM Tech Round 4 (Div. 2)(A,暴力,B,组合数,C,STL+排序)

    A. Diversity time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

随机推荐

  1. Mac 显示 Finder 隐藏文件

    显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏Mac隐藏文件的命令:defaults writ ...

  2. 使用python实现栈和队列

    1.使用python实现栈: class stack(): def __init__(self): self.stack = [] def empty(self): return self.stack ...

  3. BZOJ4157 : 星际瘟疫

    首先剔除所有从$R$不可到达的点,然后用Lengauer-Tarjan算法建立出以$R$为起点的Dominator Tree. 那么对于每个询问,求出那些点的父亲的LCA,那么答案就是LCA到根路径上 ...

  4. 【转】SpringTest框架JUnit单元测试用例获取ApplicationContext实例的方法

    转自:http://www.coderli.com/junit-spring-test-applicationcontext JUnit单元测试用例中使用Spring框架,直接方式如下. @RunWi ...

  5. android 第三方 Im

    1.阿里百川 单聊.群聊.客服能力集成,仅需花费4小时,不收费,0成本接入,让App轻松拥有沟通能力,历经多次双十一考验,消息到达率100%,全年可用性高达99.99%,登录异常提醒,木马钓鱼网站监测 ...

  6. 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法

    使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...

  7. 《DON'T MAKE ME THINK》/《点石成金访客至上的网页设计秘笈》 读书笔记

    1.web页面要尽可能简单,让用户不用思考就能知道页面的功能,如果要进行一些崭新的.开拓性的或者非常复杂的页面设计时, 此时要利用页面元素的外观.精心选择的名称.页面布局以及少量仔细斟酌过的文字,使页 ...

  8. Android -- TextView、button方法详解(2)

    1. button按下状态的改变 Button bt1 = null; // 声明按钮对象 bt1 = (Button) findViewById(R.id.button1); // 获取按钮对象 b ...

  9. SQL 学习笔记

    1.判断数据库中某个值是否为null(而不是'null',空字符串'',若干个空格' ') 一定不能用=null 或 !=null,而要用is null 或 is not null. 2.在sqlse ...

  10. Linux_CentOS6.5安装vncserver实现图形化访问

    一. 安装gnome图形化桌面 #yum groupinstall -y "X Window System" #yum groupinstall -y "Desktop& ...