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. D. Tavas and Malekas DFS模拟 + kmp + hash || kmp + hash

    http://codeforces.com/contest/535/problem/D 如果真的要把m个串覆盖上一个串上面,是可以得,不会超时. 要注意到一点,全部覆盖后再判断时候合法,和边放边判断, ...

  2. DoTween学习笔记

    using DG.Tweening:   Tweener 首先dotween在游戏刚开始运行时会默认进行一次初始化 DOTween.Init(); 如果为了有更好的效率,可以手动控制最大同时进行dot ...

  3. 从零开始docker部署flask

    1.下载一个Ubuntu镜像 2.启动镜像,使用apt-get安装python.安装pip,建议也装个vim吧 3.通过以上的容器生成一个新的镜像,命令如下docker commit afcaf46e ...

  4. Java基础50题test3—水仙花数

    水仙花数 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例 如:153 是一个"水仙花数", ...

  5. Git之删除分支

    目录 删除本地分支 删除远程分支 删除本地分支: git branch -d dev  [git branch -参数 本地分支名称] 删除远程分支: git push origin --delete ...

  6. 生成器的send方法

    send 和next区别 next:唤醒并继续执行 send:唤醒并继续执行 发送信息到生成器内部. def fib(max): n,a,b = 0,0,1 while n < max: msg ...

  7. [ CQOI 2018 ] 异或序列

    \(\\\) Description 给出一个长为 \(n\) 的数列 \(A\) 和 \(k\),多次询问: 对于一个区间 \([L_i,R_i]\),问区间内有多少个不为空的子段异或和为 \(k\ ...

  8. SEO & HTML语义化

    SEO SEO的概念:搜索引擎优化,常见的搜索引擎有百度.谷歌等.优化的话,就是通过我们的处理,使得我们的网站在搜索引擎下有一个理想的结果. SEO的目的:当用户在搜索引擎上搜索关键词的时候,看到我们 ...

  9. #error和#line使用分析

    #error的用法 #error用于生成一个编译错误消息 用法:error message(不需要用双引号包围) #error编译指示字用于自定义程序员特有的编译错误,消息类似的 #warning用于 ...

  10. nodejs,python,sublime和Eclipse的包管理器

    Python的包管理器叫pip. 首先安装Python运行环境Python 3.7.0:https://www.python.org/downloads/release/python-370/ Pyt ...