AIM Tech Round 3 (Div. 2) A B C D
虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场
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的更多相关文章
- 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 ...
- AIM Tech Round 3 (Div. 2)
#include <iostream> using namespace std; ]; int main() { int n, b, d; cin >> n >> ...
- AIM Tech Round 3 (Div. 2) B
Description Vasya takes part in the orienteering competition. There are n checkpoints located along ...
- 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 ...
- 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 ...
- AIM Tech Round 3 (Div. 2) B 数学+贪心
http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-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 ...
- 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 ...
- 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 ...
随机推荐
- js不间断平滑地自动向上滚动
<html> <head> <title>scroll up auto smooth</title> <style> *{ margin: ...
- 对于div的右浮动会导致顺序会改变
当我们设置几个div右浮动的时候会出现顺序的改变,直接倒序了. 解决的方法是在几个div外面加上一个大的div即可,但是里面的所有div都要左浮动才行,具体做法如下: <!DOCTYPE htm ...
- 解决ADT升级报错
方法一: 将https://dl-ssl.google.com/android/eclipse/ 改成 http://dl-ssl.google.com/android/eclipse/: 方法二: ...
- java-嵌套类
浏览以下内容前,请点击并阅读 声明 java允许在一个类中定义另外一个类,这就叫类嵌套.类嵌套分为两种,静态的称为静态嵌套类,非静态的又称为内部类. 使用嵌套类的原因: 能够将仅在一个地方使用的类合理 ...
- WPF Datagrid multiple selecteditems in MVVM
I can assure you: SelectedItems is indeed bindable as a XAML CommandParameter After a lot of digging ...
- ural 1342. Enterprise
1342. Enterprise Time limit: 5.0 secondMemory limit: 64 MB To bind a broom it’s a hard work. As ther ...
- 【SQL】区分新来顾客和再访顾客
-- 赋值 客户来访记录 SELECT m.* FROM (SELECT x.*, CASE WHEN x.ts > (SELECT MIN(a.ts) FROM USER.ps_afterre ...
- ACM Color the fence
Color the fence 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Tom has fallen in love with Mary. Now Tom w ...
- Leetcode Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...
- window 安装Mysql 5.6 发生系统错误 1067
问题: #安装MySQL服务:mysqld -install MySQL5 D:\Program Files\mysql_5.6.24_winx64\bin>mysqld -install My ...