“楼下一个男人病得要死,那间隔壁的一家唱着留声机,对面是弄孩子。楼上有两人狂笑;还有打牌声。河中的船上有女人哭着她死去的母亲。人类的悲欢并不相通,我只觉得他们吵闹。”

A - XORwice

把a和b看成二进制数处理,不难发现只要a,b某位都是1我们就有办法把它消掉,否则答案该位一定是a+b(0,1)该位的值

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{IO;int T=1;cin>>T;while(T--){int a,b;cin>>a>>b;int res=0;for(int i=30;i>=0;i--)if(!(a>>i&1)&&(b>>i&1)||(a>>i&1)&&!(b>>i&1)) res+=1<<i;cout<<res<<'\n';}return 0;
}

B - Putting Bricks in the Wall

我们只要让g[1][2]g[2][1]的值相等并且不等于g[n][n-1]g[n-1][n]的值即可,最多操作3步。

懒得想了,直接枚举(24=162^4=1624=16),应该有更好写的写法。

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=210;
char g[N][N];
int main()
{IO;int T=1;cin>>T;while(T--){int n;cin>>n;for(int i=1;i<=n;i++) cin>>g[i]+1;if(g[1][2]=='0'&&g[2][1]=='0'&&g[n][n-1]=='0'&&g[n-1][n]=='0') cout<<2<<'\n'<<1<<' '<<2<<'\n'<<2<<' '<<1<<'\n';else if(g[1][2]=='1'&&g[2][1]=='0'&&g[n][n-1]=='0'&&g[n-1][n]=='0')cout<<1<<'\n'<<2<<' '<<1<<'\n';else if(g[1][2]=='0'&&g[2][1]=='1'&&g[n][n-1]=='0'&&g[n-1][n]=='0')cout<<1<<'\n'<<1<<' '<<2<<'\n';else if(g[1][2]=='1'&&g[2][1]=='1'&&g[n][n-1]=='0'&&g[n-1][n]=='0')cout<<0<<'\n';else if(g[1][2]=='0'&&g[2][1]=='0'&&g[n][n-1]=='1'&&g[n-1][n]=='0')cout<<1<<'\n'<<n-1<<' '<<n<<'\n';else if(g[1][2]=='1'&&g[2][1]=='0'&&g[n][n-1]=='1'&&g[n-1][n]=='0')cout<<2<<'\n'<<2<<' '<<1<<'\n'<<n<<' '<<n-1<<'\n';else if(g[1][2]=='0'&&g[2][1]=='1'&&g[n][n-1]=='1'&&g[n-1][n]=='0')cout<<2<<'\n'<<2<<' '<<1<<'\n'<<n<<' '<<n-1<<'\n';else if(g[1][2]=='1'&&g[2][1]=='1'&&g[n][n-1]=='1'&&g[n-1][n]=='0')cout<<1<<'\n'<<n<<' '<<n-1<<'\n';else if(g[1][2]=='0'&&g[2][1]=='0'&&g[n][n-1]=='0'&&g[n-1][n]=='1')cout<<1<<'\n'<<n<<' '<<n-1<<'\n';else if(g[1][2]=='1'&&g[2][1]=='0'&&g[n][n-1]=='0'&&g[n-1][n]=='1')cout<<2<<'\n'<<1<<' '<<2<<'\n'<<n<<' '<<n-1<<'\n';else if(g[1][2]=='0'&&g[2][1]=='1'&&g[n][n-1]=='0'&&g[n-1][n]=='1')cout<<2<<'\n'<<1<<' '<<2<<'\n'<<n-1<<' '<<n<<'\n';else if(g[1][2]=='1'&&g[2][1]=='1'&&g[n][n-1]=='0'&&g[n-1][n]=='1')cout<<1<<'\n'<<n-1<<' '<<n<<'\n';else if(g[1][2]=='0'&&g[2][1]=='0'&&g[n][n-1]=='1'&&g[n-1][n]=='1')cout<<0<<'\n';else if(g[1][2]=='1'&&g[2][1]=='0'&&g[n][n-1]=='1'&&g[n-1][n]=='1')cout<<1<<'\n'<<1<<' '<<2<<'\n';else if(g[1][2]=='0'&&g[2][1]=='1'&&g[n][n-1]=='1'&&g[n-1][n]=='1')cout<<1<<'\n'<<2<<' '<<1<<'\n';else    cout<<2<<'\n'<<1<<' '<<2<<'\n'<<2<<' '<<1<<'\n';}return 0;

C - Palindromifier

abcdef→(edcb)abcdef→edcbabcdef(edcba)→edcbabcdefedcba(bcde)abcdef \to (edcb)abcdef\to edcbabcdef(edcba)\to edcbabcdefedcba(bcde)abcdef→(edcb)abcdef→edcbabcdef(edcba)→edcbabcdefedcba(bcde)
只要三步直接搞出来,可以配合代码和上述例子食用

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{IO;int T=1;//cin>>T;while(T--){string s;cin>>s;int n=s.size();cout<<3<<'\n';cout<<"L "<<n-1<<'\n';cout<<"R "<<n-1<<'\n';cout<<"R "<<2*n-1<<'\n';}return 0;}

D - Hexagons

六个方向分别让坐标的变化:
c1:(x+1,y+1)c_1:(x+1,y+1)c1​:(x+1,y+1)
c2:(x,y+1)c_2:(x,y+1)c2​:(x,y+1)
c3:(x−1,y)c_3:(x-1,y)c3​:(x−1,y)
c4:(x−1,y−1)c_4:(x-1,y-1)c4​:(x−1,y−1)
c5:(x,y−1)c_5:(x,y-1)c5​:(x,y−1)
c6:(x+1,y)c_6:(x+1,y)c6​:(x+1,y)

不难发现操作c2+c6=c1c_2+c_6=c_1c2​+c6​=c1​、c3+c5=c4c_3+c_5=c_4c3​+c5​=c4​
因此从两方面考虑是否使用c1c_1c1​和c4c_4c4​操作
如果不使用那么只通过单独进行横坐标±1和纵坐标±1到达目的地直接算即可。
如果使用那么首先使得最终向x坐标和向y坐标移动的步数(dx=dy)相等,于是考虑先通过横坐标±1或者纵坐标±1操作使最终dx=dy,然后再通过c1c_1c1​或者c4c_4c4​操作使之到达目的地。
不过注意等效操作c2+c6=c1c_2+c_6=c_1c2​+c6​=c1​、c3+c5=c4c_3+c_5=c_4c3​+c5​=c4​取代价更小的。

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll c[10];
int main()
{IO;int T=1;cin>>T;while(T--){ll x,y;cin>>x>>y;for(int i=1;i<=6;i++) cin>>c[i];ll res=8e18;ll now=0;// +x 6// -x 3// +y 2// -y 5// 不用c1和c4if(x>=0&&y>=0)now=c[6]*x+c[2]*y;else if(x>=0&&y<0)now=c[6]*x+c[5]*(-y);else if(x<0&&y>=0)now=c[3]*(-x)+c[2]*y;elsenow=c[3]*(-x)+c[5]*(-y);res=min(res,now);// 使用c1和c4if(x>y){now=0;now+=c[5]*(x-y);if(x>=0) now+=min(c[1],c[2]+c[6])*x;else now+=min(c[4],c[3]+c[5])*(-x);res=min(res,now);now=0;now+=c[6]*(x-y);if(y>=0) now+=min(c[1],c[2]+c[6])*y;else now+=min(c[4],c[3]+c[5])*(-y);res=min(res,now);}else{now=0;now+=c[3]*(y-x);if(y>=0) now+=min(c[1],c[2]+c[6])*y;else now+=min(c[4],c[3]+c[5])*(-y);res=min(res,now);now=0;now+=c[2]*(y-x);if(x>=0) now+=min(c[1],c[2]+c[6])*x;else now+=min(c[4],c[3]+c[5])*(-x);res=min(res,now);}cout<<res<<'\n';}return 0;
}

吐槽一波,这题debug了半天竟然是上限搞小了,自己一般开101810^{18}1018结果有数据的答案比该值还大,最终把最大值开到8×10188×10^{18}8×1018才过的。。。

刚刚看了一波别人的题解,发现D题只需要把所有等效操作的代价取个最小值即可,没必要这样讨论,嗨自己还是太菜了

E - Swedish Heroes

这题好像是dp,以后回补的!

最近学业压力有点重,而且快期中考试了。。。这周六还有校赛,希望能打出好成绩。

Codeforces Round #676 (Div. 2) E待补相关推荐

  1. Codeforces Round #676 (Div. 2) A - D个人题解(E题待补)

    1421A. XORwice 题目链接:Click Here cpp // Author : RioTian // Time : 20/10/18 #include <bits/stdc++.h ...

  2. Codeforces Round #701 (Div. 2)赛后补题报告(A~D)

    Codeforces Round #701 (Div. 2)赛后补题报告(A~D) A. Add and Divide 原题信息 http://codeforces.com/contest/1485/ ...

  3. Codeforces Round #727 (Div. 2) E. Game with Cards dp + 思维

    传送门 文章目录 题意: 思路: 题意: 初始有左右手,上面各有一个数字为000的卡牌,每次都有一个新卡kik_iki​,你可以将其放在左手或者右手,使两只手上的卡片范围在[ll,i,rl,i][l_ ...

  4. Codeforces Round #709 (Div. 1) B. Playlist 链表维护 + bfs

    传送门 文章目录 题意: 思路: 题意: 思路: 紧跟刘爷脚步补题. 不难想到用链表维护下一个数是什么,这样就跟以前做过的一个题差不多了,首先将初始的时候删掉的点的前一个点即为题目中的AAA入队,让后 ...

  5. CodeCraft-21 and Codeforces Round #711 (Div. 2)

    CodeCraft-21 and Codeforces Round #711 (Div. 2) 题号 题目 考点 A GCD Sum 签到,模拟 B Box Fitting 贪心 C Planar R ...

  6. Codeforces Round #434 (Div. 2)【A、B、C、D】

    Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...

  7. Codeforces Round #700 (Div. 2)A~D2解题报告

    Codeforces Round #700 (Div. 2)A~D2解题报告 A Yet Another String Game 原题链接 http://codeforces.com/contest/ ...

  8. Codeforces Round #739 (Div. 3) ABCDEF1F2 解题思路

    Codeforces Round #739 (Div. 3) 可能是一开始大佬都写F1去了,我在D写完后发现F过的人数比E多了好多(个位数与十位数),以为F1比较简单,就直接开F1了,但自己分类讨论老 ...

  9. Codeforces Round #817 (Div. 4)

    发挥还行,约了三五好友一起打,不过有点晚,该睡了,睡前简单写一波题解,明天记得补题 Dashboard - Codeforces Round #817 (Div. 4) - Codeforces 完成 ...

最新文章

  1. nginx安装 问题 1
  2. SpringBoot+Mybatis+ Druid+PageHelper 实现多数据源并分页
  3. 为所有PHP-FPM容器构建单独的NGinx Dock镜像
  4. excel xml mysql_数据库表转换为xml格式,excel转换为xml格式文件
  5. php求链表中位数,先给伸手党的php链表遍历求和
  6. 二进制搜索树_数据结构101:二进制搜索树
  7. 警告—系统—srv—2013—无
  8. hibernate一对多映射实现
  9. 【软件测试】软件测试的基本流程(一般步骤)
  10. python生成词云教程(附带QQ聊天记录生成词云实战)
  11. [Matlab]中pcolor和colormap的使用
  12. matlab ode 实数,关于ode45中erf函数(输入必须为实数完全数的报错问题)
  13. 今日头条关键词文章热度和搜索指数的查询方法分享
  14. 使用POI导出Excel时,关于设置带有多行表头表格自动宽度的问题解决办法
  15. 在不格式化U盘的情况下查杀U盘快捷方式病毒
  16. Python培训得多少钱
  17. 2023计算机毕业设计SSM最新选题之javaJava班级信息管理系统x0w9c
  18. 让每个生命带着尊严谢幕!淘宝竟有这样一家“临终关怀”网店
  19. <<算法很美>>——(七)——DFS典题(二):数独游戏
  20. Day 05- Vue3 Vue2响应式原理

热门文章

  1. 巨型机是一种什么的超级计算机,这个世界其实是一个超级计算机
  2. 中断原理在计算机中的应用,最新 计算机原理与应用 复习3-判断题
  3. c语言整数四则运算表达式的输出格式控制,Educoder CC++基本输入输出
  4. android中的帧动画,[Android开发] Android中的帧动画
  5. 离线语音识别软件_从音乐识别软件起家,这家公司如何备战车载AI语音市场GGAI对话...
  6. 利用vector实现一对一(pair<int,int>)
  7. [Redis6]跳跃表(跳表)
  8. [Spring5]AOP底层原理
  9. [Java基础]抽象类基础
  10. dfs递归实现组合型枚举