Codeforces Round #676 (Div. 2) A - D个人题解(E题待补)
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题待补)的更多相关文章
- Codeforces Round #604 (Div. 2) A,B,C【D题待补】
思路:直接暴力判断就OK了 #include<bits/stdc++.h> using namespace std; #define int long long signed main() ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #676 (Div. 2)【ABCD】
比赛链接:https://codeforces.com/contest/1421 A. XORwice 题意 给出两个正整数 \(a.b\),计算 \((a \oplus x) + (b \oplus ...
- 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 ...
- Codeforces Round #354 (Div. 2) A. Nicholas and Permutation 水题
A. Nicholas and Permutation 题目连接: http://www.codeforces.com/contest/676/problem/A Description Nichol ...
- Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...
- 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 ...
随机推荐
- 浅谈Charles —— 青花瓷
Charles -- 青花瓷 网络抓包工具 可以拦截 iPhone/Android 手机中 App 的非加密网络请求数据 使用 手机&电脑在同一个局域网 确保电脑能够通过路由器访问互联网 电脑 ...
- 从CSDN博客下载的图片如何无损去水印
如果你想下载别人CSDN博客文章中很好看的图片,但却有水印 想要下载去水印的图片,可以先鼠标右击该图片,选择复制图片地址 https://img-blog.csdnimg.cn/20200916140 ...
- python文档翻译之概述
Python是一个使用方便且功能强大的变成语言.它具有高效的高级数据结构和面向对象编程特性.其优雅的语法.动态类型.解释型特性使得它成为大多数平台上脚本和快速应用程序开发的理想语言. Python解释 ...
- 3.GoolgeProtoBuffer序列化反序列化
- Object类:又回到最初的起点
Object类大概是每个JAVA程序员认识的第一个类,因为它是所有其他类的祖先类.在JAVA单根继承的体系下,这个类中的每个方法都显得尤为重要,因为每个类都能够调用或者重写这些方法.当你JAVA学到一 ...
- MyBatis学习(三)日志输出环境配置
一.编写日志输出环境配置文件 在开发过程中,最重要的就是在控制台查看程序输出的日志信息,在这里我们选择使用 log4j 工具来输出: 准备工作:将[MyBatis]文件夹下[lib]中的 log4j ...
- Ubuntu18.04安装常用软件指南
安装中文版火狐浏览器 第一步:先卸载:sudo apt-get remove firefox第二步:安装:sudo apt-get install firefox第三步:设置成中文:sudo apt- ...
- 《Duubo系列》-Dubbo服务暴露过程
我今天来就带大家看看 Dubbo 服务暴露过程,这个过程在 Dubbo 中其实是很核心的过程之一,关乎到你的 Provider 如何能被 Consumer 得知并调用. 今天还是会进行源码解析,毕竟我 ...
- 曹工说Tomcat:200个http-nio-8080-exec线程全都被第三方服务拖住了,这可如何是好(上:线程模型解析)
前言 这两年,tomcat慢慢在新项目里不怎么接触了,因为都被spring boot之类的框架封装进了内部,成了内置server,不用像过去那样打个war包,再放到tomcat里部署了. 但是,内部的 ...
- (一)jenkins+git+docker
目录 一.发布流程设计 1.工作流程 2.环境规划如下 二.部署Git仓库 1.创建Git用户并设置密码 2.创建仓库 3.免密访问 4.在jenkins那台机上做ssh认证 三.准备Jenkins环 ...