A. Santa Claus and a Place in a Class

模拟题。(0:12)

题意:n列桌子,每列m张桌子,每张桌子一分为2,具体格式看题面描述。给出n,m及k。求编号为k的桌子在第几行第几列是左还是右。

思路:由图知k为奇数在左边。每列有2*m个数,k/(2*m)然后就可以知道在第几列。然后数据小遍历找到第几行。

int main()
{
int n,m,k;
while(~scanf("%d%d%d",&n,&m,&k))
{
char c;
if(k%2) c='L';
else c='R';
int x=0,y=0;
y=k/(2*m);
if(k%(2*m)) y++;
k-=(y-1)*2*m;
while(k>0)
{
k-=2;
x++;
}
printf("%d %d %c\n",y,x,c);
}
return 0;
}

B. Santa Claus and Keyboard Check

贪心模拟题。(0:39)

题意:真没读懂,大概知道了样例怎么来的。给出两个串,每个字符可以唯一对应(变成)另外一个字符,问如果第一个字符串可以变为另外一个串,输出对应要变的字符。

思路:就是一顿乱判,用map存对应关系,可能是样例比较水吧,侥幸过了终判。

struct node
{
char x,y;
}a1[N];
int main()
{
string a,b;
cin>>a>>b;
if(a==b)
{
printf("0\n");
}
else
{
int f=0,len=0;
int len1=a.size();
int len2=b.size();
if(len1!=len2) f=1;
map<char,char>q;
int v[50];
memset(v,0,sizeof(v));
memset(a1,'0',sizeof(a1));
for(int i=0;i<len1&&i<len2;i++)
{
if(a[i]==b[i])
{
if(v[a[i]-'a']||v[b[i]-'a']) //已经有主了;
{
if(v[a[i]-'a']&&q[a[i]]!=b[i]) f=1;
if(v[b[i]-'a']&&q[b[i]]!=a[i]) f=1;
}
else q[a[i]]=b[i];
}
else
{
if(v[a[i]-'a']||v[b[i]-'a'])
{
if(v[a[i]-'a']&&q[a[i]]!=b[i]) f=1;
else if(v[b[i]-'a']&&q[b[i]]!=a[i]) f=1;
}
else
{
q[a[i]]=b[i];
q[b[i]]=a[i];
a1[len].x=a[i];
a1[len++].y=b[i];
}
}
v[a[i]-'a']=1;
v[b[i]-'a']=1;
}
if(f) printf("-1\n");
else
{
printf("%d\n",len);
for(int i=0;i<len;i++)
printf("%c %c\n",a1[i].x,a1[i].y);
}
}
return 0;
}

C. Santa Claus and Robot

侥幸过了终判,中间WA了一发。(1:41)

题意:有一个串,只包含‘U’、‘L’、'R'、‘D’四种字符,分别表示往哪个方向走。小明要走一个序列,起点为p0,每次从pi走到pi+1(1<=i<n)。小明只会沿着格子走最短路。但路线可能有很多种。求n的最小值。

思路:由最后一个图发现每次经过一个点都走了相反的路线。一去一回这这便经过了一个点。所以求有多少相反对即可。(U和D、L和R分别为一个相反对)

int main()
{
int n;
int v[50];
memset(v,0,sizeof(v));
string a;
cin>>n>>a;
int ans=0;
char c=a[0];//当前状态,表示走的方向
for(int i=0;i<n;i++)
{
if((c=='L'&&a[i]=='R')||(c=='R'&&a[i]=='L')||(c=='U'&&a[i]=='D')||(c=='D'&&a[i]=='U'))//遇到相反对
{
c=a[i];//更新当前状态
ans++;
memset(v,0,sizeof(v));
v[a[i]-'A']=1;
continue;
}
if(c=='L'||c=='R')
{
if((a[i]=='U'&&v['D'-'A'])||(a[i]=='D'&&v['U'-'A']))
{
c=a[i];
ans++;
memset(v,0,sizeof(v));
}
v[a[i]-'A']=1;
}
else
{
if((a[i]=='L'&&v['R'-'A'])||(a[i]=='R'&&v['L'-'A']))
{
c=a[i];
ans++;
memset(v,0,sizeof(v));
}
v[a[i]-'A']=1;
}
}
ans++;//终点
printf("%d\n",ans);
return 0;
}

C题刚想到这个思路的时候学姐给了一个想法:每两个点之间只有两种方向。。。但按着这种思路WA在第六组了。。。

Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) 圣诞之夜!的更多相关文章

  1. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C

    Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...

  2. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B

    Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...

  3. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A

    Description Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the f ...

  4. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

  5. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  6. Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)

    http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...

  7. codeforces Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)// 二分的题目硬生生想出来ON的算法

    A. Road to Cinema 很明显满足二分性质的题目. 题意:某人在起点处,到终点的距离为s. 汽车租赁公司提供n中车型,每种车型有属性ci(租车费用),vi(油箱容量). 车子有两种前进方式 ...

  8. Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) E. Subordinates 贪心

    E. Subordinates time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) D. Sea Battle 模拟

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. 在 CentOS 环境下安装 .NET Core

    安装步骤: 参见官网 CentOS 会报以下错误: Error downloading packages: dotnet-runtime-2.2-2.2.4-1.x86_64: [Errno 256] ...

  2. AJPFX:实现递归统计文件夹的总大小

    class Statistical {    public static void main(String[] args) {        Scanner sc = new Scanner(Syst ...

  3. calc() 计算CSS属性值

    calc()是css3的一个新增的功能,用来指定元素的长度.比如说,你可以使用calc()给元素的border.margin.pading.font-size和width等属性设置动态值.calc() ...

  4. 秦晓波著的编写高质量代码-改善Java程序的151个建议一书中的线程解释错误.

    位置: 建议127: Lock与synchronized是不一样的 首先在概念上纠正这一篇内容: 援引Java源码中关于ReentrantLock的开篇说明: * A reentrant mutual ...

  5. CENTOS6.4上KVM虚拟机环境搭建

    CENTOS6.4上KVM虚拟机环境搭建   关键词: KVM,虚拟机,windows7, VNC, 桥接网络,br0, SCSI, IDE   环境: host: CENTOS6.4 guest: ...

  6. Ubuntu16.04常用操作命令总结ing

    查看软件安装目录:whereis 软件名称(如:whereis mysql,where is sqlite3等) 安装软件:apt/apt-get install 软件名称(如:apt/apt-get ...

  7. js图片轮播效果常见的产品无缝轮播

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  8. SQLite – LIMIT子句

    SQLite - LIMIT子句 SQLite LIMIT子句是用来限制SELECT语句返回的数据量. 语法: SELECT语句.LIMIT子句的基本语法如下: SELECT column1, col ...

  9. hql语法001

    1. import java.util.List; import org.hibernate.*; import org.junit.Test; import cn.jbit.hibernatedem ...

  10. vux安装

    1. 在项目里安装vux cnpm install vux --save 2. 安装vux-loader cnpm install vux-loader --save-dev 3. 安装less-lo ...