1421A. XORwice

题目链接:Click Here

// Author : RioTian
// Time : 20/10/18
#include <bits/stdc++.h>
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;
typedef long long ll;
ll n, m, _;
void solve() {
cin >> n >> m;
cout << (n ^ m) << endl;
}
int main() {
// freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _;
while (_--) solve();
}

1421B. Putting Bricks in the Wall

题目链接:Click Here

如果选择S的邻居为1,我们就可以F使为0的邻居,就没有办法从S到F,但这在最坏的情况下需要4个开关,这是不够的。 幸运的是,为了减少到2个开关,只需反过来考虑,使相邻S的正方形变为0,使相邻的正方形变为F 1。必须存在最多具有两个开关的两个正方形的解,并且您不会从S到F,因为被迫选择1(或0),并且无法通过与F相反的邻居。

// Author : RioTian
// Time : 20/10/18
#include <bits/stdc++.h>
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;
typedef long long ll;
ll n, m, _;
char x[210][210];
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> x[i] + 1;
int a = x[1][2] - '0', b = x[2][1] - '0', c = x[n][n - 1] - '0',
d = x[n - 1][n] - '0';
if (a == b && c == d && a != c)
cout << 0 << endl;
else if (a != b && c != d)
cout << 2 << endl
<< 1 << " " << 2 << endl
<< (a == c ? n - 1 : n) << " " << (a == c ? n : n - 1) << endl;
else if (a != b)
cout << 1 << endl
<< (a == c ? 1 : 2) << ' ' << (a == c ? 2 : 1) << endl;
else if (c != d)
cout << 1 << endl
<< (a == c ? n : n - 1) << ' ' << (a == c ? n - 1 : n) << endl;
else
cout << 2 << endl << 1 << ' ' << 2 << endl << 2 << " " << 1 << endl;
}
int main() {
// freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _;
while (_--) solve();
}
#python
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split())) t,=I()
for _ in range(t):
n,=I()
l=[input().strip() for i in range(n)]
an=[]
le=[0,0,1,1,1];p=[1,1,0,0,0]
rq=[l[0][1],l[1][0],l[1][1],l[2][0],l[0][2]]
pos=[[1,2],[2,1],[2,2],[3,1],[1,3]]
ct=cp=0;a1=[]
for i in range(5):
if le[i]!=int(rq[i]):
ct+=1
a1.append(pos[i])
for i in range(5):
if p[i]!=int(rq[i]):
cp+=1
an.append(pos[i])
if ct<=cp:
an=a1
print(len(an))
for i in an:
print(*i)

1421C. Palindromifier

题目链接:Click Here

这道题写的挺懵的,一开始都没理解题意

被dalao提醒以后然后发现是构造题,根据题目说的两种方案:

对于任何字符串都可以先 $L ,i = 2 \(,然后\)R,i = 2 $ + \(R, i = 7\)。一定能构造需所需的字符串

// Author : RioTian
// Time : 20/10/18
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> s;
cout << "3\nL 2\nR 2\n";
cout << "R " << 2 * s.size() - 1 << endl;
}
print('3\nL 2\nR 2\nR',len(input())*2-1)

1421D. Hexagons (补)

题目链接:Click Here

// Author : RioTian
// Time : 20/10/18
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int inf = 1e9 + 7;
ll x, y, c1, c2, c3, c4, c5, c6;
ll check(ll ad) {
ll ans = 0;
if (ad > 0)
ans += ad * c1;
else
ans += -ad * c4;
if (x - ad > 0)
ans += (x - ad) * c6;
else
ans += (ad - x) * c3;
if (y - ad > 0)
ans += (y - ad) * c2;
else
ans += (ad - y) * c5;
return ans;
}
void solve() {
cin >> x >> y >> c1 >> c2 >> c3 >> c4 >> c5 >> c6;
ll l = -inf, r = inf;
while (l < r) {
ll mid = l + r >> 1;
if (check(mid) < check(mid + 1))
r = mid;
else
l = mid + 1;
}
cout << min({check(l), check(l + 1), check(l - 1)}) << '\n';
}
int main() {
int t;
cin >> t;
while (t--) solve();
}

1421E. Swedish Heroes (补)

题目链接:Click Here

Codeforces Round #676 (Div. 2) A - D个人题解(E题待补)的更多相关文章

  1. Codeforces Round #604 (Div. 2) A,B,C【D题待补】

    思路:直接暴力判断就OK了 #include<bits/stdc++.h> using namespace std; #define int long long signed main() ...

  2. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  3. Codeforces Round #298 (Div. 2) A、B、C题

    题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...

  4. Codeforces Round #267 (Div. 2) C. George and Job(DP)补题

    Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently ...

  5. Codeforces Round #676 (Div. 2)【ABCD】

    比赛链接:https://codeforces.com/contest/1421 A. XORwice 题意 给出两个正整数 \(a.b\),计算 \((a \oplus x) + (b \oplus ...

  6. Codeforces Round #676 (Div. 2) XORwice、Putting Bricks in the Wall、Palindromifier

    题目链接:XORwice 题意:给你两个数a.b.求一个数x,使得((a异或x)+(b异或x))这个值最小,输出最小那个x 题解: 输出(a|b)-(a&b)就行(猜了一手 代码: #incl ...

  7. Codeforces Round #354 (Div. 2) A. Nicholas and Permutation 水题

    A. Nicholas and Permutation 题目连接: http://www.codeforces.com/contest/676/problem/A Description Nichol ...

  8. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

  9. Codeforces Round #384 (Div. 2) A. Vladik and flights 水题

    A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...

随机推荐

  1. SpringCloud OpenFeign Post请求的坑

    在微服务开发中SpringCloud全家桶集成了OpenFeign用于服务调用,SpringCloud的OpenFeign使用SpringMVCContract来解析OpenFeign的接口定义. 但 ...

  2. 面试官写了个双冒号: : 问我这是什么语法?Java中有这玩意?

    一:简洁 方法引用分为三种,方法引用通过一对双冒号:: 来表示,方法引用是一种函数式接口的另一种书写方式 静态方法引用,通过类名::静态方法名, 如 Integer::parseInt 实例方法引用, ...

  3. Java源码赏析(一)Object 类

    写这个系列的原因,其实网上已经有无数源码分析的文章了,多一篇不多,少一篇不少,但为什么还要写这部分文章呢?于私,其一,上班族已经很久没有打过完整的一整段有意义的话,算是锻炼个人的书写.总结能力,其二, ...

  4. 精心总结ansible-playbook剧本的这6种变量

    #变量作用 #根据需求灵活修改,如:需要安装不同版本号的服务,或进行版本升级回退等 1.通过vars定义变量 #1.1.定义一个变量 version: 1.1.2 #定义多个变量 vars: - v1 ...

  5. python协程(yield、asyncio标准库、gevent第三方)、异步的实现

    引言 同步:不同程序单元为了完成某个任务,在执行过程中需靠某种通信方式以协调一致,称这些程序单元是同步执行的. 例如购物系统中更新商品库存,需要用"行锁"作为通信信号,让不同的更新 ...

  6. python3的基础数据类型

    看了很多文档,想自己整理一下关于python的数据类型.说干就干,下面接上. 首先,了解 常量与变量. 常量是什么?常量是指在整个程序操作过程中其值保持不变的数据: 变量是什么?变量即在程序运行过程中 ...

  7. ACMer不得不会的线段树,究竟是种怎样的数据结构?

    大家好,欢迎阅读周三算法数据结构专题,今天我们来聊聊一个新的数据结构,叫做线段树. 线段树这个数据结构很多人可能会有点蒙,觉得没有听说过,但是它非常非常有名,尤其是在竞赛圈,可以说是竞赛圈的必备技能. ...

  8. JAVA对象转换为JSON及日期格式转换处理

    1.JSON日期格式转换 默认JSON对DATE类型会转换成一个多属性对象, 而不是单独的一个字符串, 在某些应用处理上不是很方便,  可以利用JsonValueProcessor来实现日期的转换. ...

  9. 04 C语言基本语法

    C语言的令牌 C 语言的程序代码由各种令牌组成,令牌可以是关键字.标识符.常量.字符串值,或者是一个符号.例如,下方的C语句包括5个令牌: printf("Hello, World! \n& ...

  10. Tensorflow学习笔记No.0

    这里更新一些学习Tensorflow过程中可能用到的实用工具. Jupyter Notebook Jupyter Notebook 是一个非常方便的python编程工具,支持可视化,对于学习pytho ...