CodeForces754A

题意:

给一个数组,让你变成1-n,输出变换区间,要求原区间和不为0.

思路:

如果原数组不为0,那就是YES;

如果为0,则从1开始扫过去,碰到不为0时,分两个区间[1,k],[k+1,n]

#include<bits/stdc++.h>
using namespace std; int a[110]; int main()
{
int n,i,sum;
while(~scanf("%d",&n))
{
sum=0;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
if(sum==0)
{
sum=0;
for(int s=1;s<=n;s++)
{
sum+=a[s];
if(sum)
{
if(s!=n)
{
puts("YES");
puts("2");
printf("%d %d\n",1,s);
printf("%d %d\n",s+1,n);
}
else
{
puts("YES");
printf("%d %d\n",1,n);
}
return 0;
}
}
puts("NO");
}
else
{
puts("YES");
puts("1");
printf("%d %d\n",1,n);
}
}
return 0;
}

CodeForces754B

题意:

'.' (empty cell),

 'x' (lowercase English letter x),

 'o' (lowercase English letter o).

 horizontal, vertical or diagonal有3个获胜,问能否在一部内使得有x在horizontal, vertical or diagonal连成3个。

思路:

暴力枚举horizontal, vertical or diagonal?

#include<bits/stdc++.h>
using namespace std; char ma[5][5]; bool manzu(int x)
{
if(x>=0&&x<4)
return true;
return false;
} bool judge_three(int sx,int sy,int ex,int ey)
{
int num1,num2;
int i,j;
num1=num2=0;
for(i=sx,j=sy;;)
{
if(ma[i][j]=='x') num1++;
if(ma[i][j]=='.') num2++;
if(i==ex&&j==ey)
break;
if(i<ex) i++;
if(j<ey) j++;
}
if(num1==2&&num2==1)
return true;
return false;
} bool Judge(int x,int y)
{
if(manzu(x+2))
if(judge_three(x,y,x+2,y)) return true;
if(manzu(x-2))
if(judge_three(x-2,y,x,y)) return true;
if(manzu(y+2))
if(judge_three(x,y,x,y+2)) return true;
if(manzu(y-2))
if(judge_three(x,y-2,x,y)) return true;
if(manzu(x+2)&&manzu(y+2))
if(judge_three(x,y,x+2,y+2)) return true;
if(manzu(x-2)&&manzu(y-2))
if(judge_three(x-2,y-2,x,y)) return true;
if(manzu(x+2)&&manzu(y-2))
{
int num1=0,num2=0;
if(ma[x][y]=='x') num1++;
if(ma[x][y]=='.') num2++;
if(ma[x+1][y-1]=='x') num1++;
if(ma[x+1][y-1]=='.') num2++;
if(ma[x+2][y-2]=='x') num1++;
if(ma[x+2][y-2]=='.') num2++;
if(num1==2&&num2==1) return true;
}
if(manzu(x-2)&&manzu(y+2))
{
int num1=0,num2=0;
if(ma[x][y]=='x') num1++;
if(ma[x][y]=='.') num2++;
if(ma[x-1][y+1]=='x') num1++;
if(ma[x-1][y+1]=='.') num2++;
if(ma[x-2][y+2]=='x') num1++;
if(ma[x-2][y+2]=='.') num2++;
if(num1==2&&num2==1) return true;
}
return false;
} int main()
{
for(int i=0; i<4; i++)
scanf("%s",ma[i]);
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
if(Judge(i,j))
{
puts("YES");
return 0;
}
puts("NO");
return 0;
}
/*
o.x.
o...
.x..
ooxx
*/

CodeForces599A

题意:

d1 is the length of the path  house and first shop;

d2 is the length of the path  house and second shop;

d3 is the length of the path  both shops.

思路:

显然水题

#include<bits/stdc++.h>
using namespace std; int a[110]; int main()
{
int num=0;
int d1,d2,d3;
scanf("%d%d%d",&d1,&d2,&d3);
a[num++]=d1+d2+d3;
a[num++]=2*(d1+d2);
a[num++]=2*(d1+d3);
a[num++]=2*(d2+d3);
sort(a,a+num);
printf("%d\n",a[0]);
return 0;
}

CodeForces599B

题意:

给出f[],b[];

构造ai, 使得 b[i]=f[ai]

只有一组则直接输出

有多种情况输出"Ambiguity"

如果不可能就是不可能

思路:

直接模拟。

先搞出impossible的情况,也就是没有匹配的,其次看是不是存在多个的。

然后就是输出坐标就好了。

#include<bits/stdc++.h>
using namespace std; const int N=1e5+10;
int index[N];
int f[N],a[N],n,m;
int num[N];
bool flag,flat; int main()
{
scanf("%d%d",&n,&m);
memset(num,0,sizeof(num));
for(int i=1;i<=n;i++)
{
scanf("%d",&f[i]);
index[f[i]]=i;
num[f[i]]++;
}
flag=false;
flat=false;
for(int i=1;i<=m;i++)
{
scanf("%d",&a[i]);
if(!num[a[i]])
flag=true;
if(num[a[i]]>1)
flat=true;
}
if(flag)
puts("Impossible");
else if(flat)
puts("Ambiguity");
else
{
puts("Possible");
for(int i=1;i<=m;i++)
printf("%d ",index[a[i]]);
}
return 0;
}

CodeForces水题的更多相关文章

  1. Codeforces水题集合[14/未完待续]

    Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...

  2. codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)

    题目链接:http://www.codeforces.com/problemset/problem/281/A题意:将一个英文字母的首字母变成大写,然后输出.C++代码: #include <c ...

  3. codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)

    题目链接:http://www.codeforces.com/problemset/problem/131/A题意:字符串大小写转换.C++代码: #include <cstdio> #i ...

  4. codeforces水题100道 第二十五题 Codeforces Round #197 A. Helpful Maths (Div. 2) (strings)

    题目链接:http://www.codeforces.com/problemset/problem/339/A题意:重新组合加法字符串,使得按照1,2,3的顺序进行排列.C++代码: #include ...

  5. codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)

    题目链接:http://www.codeforces.com/problemset/problem/112/A题意:忽略大小写,比较两个字符串字典序大小.C++代码: #include <cst ...

  6. codeforces水题100道 第二十三题 Codeforces Beta Round #77 (Div. 2 Only) A. Football (strings)

    题目链接:http://www.codeforces.com/problemset/problem/96/A题意:判断一个0-1字符串中出现的最长的0字串或者1字串的长度是否大于等于7.C++代码: ...

  7. codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)

    题目链接:http://www.codeforces.com/problemset/problem/118/A题意:字符串转换……C++代码: #include <string> #inc ...

  8. codeforces水题100道 第二十一题 Codeforces Beta Round #65 (Div. 2) A. Way Too Long Words (strings)

    题目链接:http://www.codeforces.com/problemset/problem/71/A题意:将长字符串改成简写格式.C++代码: #include <string> ...

  9. codeforces水题100道 第二十题 Codeforces Round #191 (Div. 2) A. Flipping Game (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/327/A题意:你现在有n张牌,这些派一面是0,另一面是1.编号从1到n,你需要翻转[i,j]区间的 ...

随机推荐

  1. WPF 后台Render线程崩溃, Exception from HRESULT: 0x88980406

    近期遇到一个问题.窗口在Loaded同一时候Resize会出现黑屏或者直接崩溃, 调查发现是WPF后端的Render线程渲染UI到DirectX时崩溃. 硬件环境:WES7 + .Net4.0 关于W ...

  2. 学习某些API的方法

    学习某些 API 的方法 这里的 API 可能是某个系统平台,开发包,开发平台,开发工具等等,因为任何系统和技术方法提供给开发者的打包方式都是一系列 API . 无论你有在哪一层级开发,从硬件驱动到系 ...

  3. 【BZOJ3218】a + b Problem 可持久化线段树优化建图

    [BZOJ3218]a + b Problem 题解:思路很简单,直接最小割.S->i,容量为Bi:i->T,容量为Wi:所有符合条件的j->new,容量inf:new->i, ...

  4. Struts2中数据封装机制

    Struts2当中数据封装的三种机制:属性驱动.标签驱动.模型驱动.下面来一一介绍. 一.属性驱动 1.需要提供对应属性的set方法进行数据的封装. 2.表单的哪些属性需要封装数据,那么在对应的Act ...

  5. cocos2d-js v3新特性

    1.游戏对象 使用cc.game单例代替了原有的cc.Application以及cc.AppControl 2.属性风格API 旧的API                                ...

  6. OpenMeetings安装

    OpenMeetings是一个开源的视频会议软件. 它是基于OpenLaszlo’s的新流媒体格式和开源的Flash服务器---Red5! 采用了flash流媒体服务器Red5+OpenMeeting ...

  7. STM32 ~ ili9341 横屏驱动代码

    void ili9341_Initializtion(void) { u16 i; RCC->APB2ENR|=<<; //使能PORTB时钟 GPIOB->CRH&= ...

  8. Algorithm: Euler function

    欧拉函数. phi(n)表示比n小的与n互质的数的个数,比如 phi(1) = 1; phi(2) = 1; phi(3) = 2; phi(4) = 2; phi(5) = 4; 性质: 1. 如果 ...

  9. P1604&P1601

    [usaco2010]冲浪_slide 受到秘鲁的马丘比丘的新式水上乐园的启发,Farmer John决定也为奶牛们建一个水上乐园.当然,它最大的亮点就是新奇巨大的水上冲浪. 超级轨道包含 E (1 ...

  10. uboot显示logo的时候发现颜色偏黄【学习笔记】

    平台信息:内核:linux3.0.68 系统:android6.0平台:rk3288 将一张图片烧录进logo分区,发现在uboot读取这张图片并显示的时候发现颜色偏黄,解决办法,在烧录bmp图片的时 ...