题目链接:XORwice

题意:给你两个数a、b。求一个数x,使得((a异或x)+(b异或x))这个值最小,输出最小那个x

题解:

输出(a|b)-(a&b)就行(猜了一手

代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int main()
{
int t;
scanf("%d",&t);;
while(t--)
{
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",(a|b)-(a&b));
}
return 0;
}

题目链接:Putting Bricks in the Wall

题意:给你一个n*n的方形,每一个小格子有一个值(除了(1,1)和(n,n))。你从一个位置只能移动到与它相邻一条边的其他位置(也就是上下左右移动)

它需要从起点(1,1)移动到终点(n,n),你要保证这条路径上所经历过的所有格子的值都一样(除了(1,1)和(n,n))

现在你可以反转最多两个格子的值(也就是把一个格子的值从0变1,或从1变0),使得找不到一条满足条件从起点(1,1)到终点(n,n)的路径

然后输出你需要反转的格子的坐标

题解:

只需要让(1,1)位置周围两个点 和(n,n)周围两个点的值变成相反的就可以了

就比如让(1,2)和(2,1)位置的值变成1,让 (n-1,n)和(n,n-1)位置的点变成0

代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int maxn=1e3+10;
const int INF=0x3f3f3f3f;
char s[maxn][maxn];
int main()
{
int t;
scanf("%d",&t);;
while(t--)
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%s",s[i]+1);
}
int one_st=0,zero_st=0,one_la=0,zero_la=0,one_st2=0,zero_st2=0,one_la2=0,zero_la2=0;
if(s[1][2]=='1')
one_st++;
else zero_st++;
if(s[2][1]=='1')
one_st2++;
else zero_st2++; if(s[n][n-1]=='1')
one_la++;
else zero_la++;
if(s[n-1][n]=='1')
one_la2++;
else zero_la2++;
int res=INF;
res=min(res,one_st2+one_st+zero_la+zero_la2);
int temp=res,flag=0;
res=min(res,zero_st2+zero_st+one_la2+one_la);
if(temp==res) flag=1;
printf("%d\n",res);
if(flag)
{
if(s[2][1]=='1')
printf("2 1\n");
if(s[1][2]=='1')
printf("1 2\n");
if(s[n][n-1]=='0')
printf("%d %d\n",n,n-1);
if(s[n-1][n]=='0')
printf("%d %d\n",n-1,n);
}
else
{
if(s[2][1]=='0')
printf("2 1\n");
if(s[1][2]=='0')
printf("1 2\n");
if(s[n][n-1]=='1')
printf("%d %d\n",n,n-1);
if(s[n-1][n]=='1')
printf("%d %d\n",n-1,n);
}
}
return 0;
}

题目链接:Palindromifier

题意:

给你一个字符串s(下标从1开始,长度为n),你有两种操作,你最多使用30次操作,你要保证经过操作之后的字符串是一个回文字符串,且这个回文字符串的长度不超过1e6

操作一、从区间[2,n-1]这个区间内挑一个x,然后把下标区间为[2,x]这一个子串倒过来(也就是abc变成cba)之后追加到原串的头部

操作二、从区间[2,n-1]这个区间内挑一个x,然后把下标区间为[x,n-1]这一个子串倒过来(也就是abc变成cba)之后追加到原串的尾部

题解:

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int INF=0x3f3f3f3f;
char s[maxn];
int main()
{
scanf("%s", s);
int l = strlen(s);
printf("3\n");
printf("R %d\n", l - 1);
printf("L %d\n", l);
printf("L 2\n");
return 0;
}
 

Codeforces Round #676 (Div. 2) XORwice、Putting Bricks in the Wall、Palindromifier的更多相关文章

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

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

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

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

  3. Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)

    D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...

  4. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  5. Codeforces Round #441 (Div. 2)【A、B、C、D】

    Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...

  6. Codeforces Round #437 (Div. 2)[A、B、C、E]

    Codeforces Round #437 (Div. 2) codeforces 867 A. Between the Offices(水) 题意:已知白天所在地(晚上可能坐飞机飞往异地),问是否从 ...

  7. 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. 题解:答案就是 ...

  8. 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 ...

  9. Codeforces Round #440 (Div. 2)【A、B、C、E】

    Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...

随机推荐

  1. .NET探索平台条件编译

    前言 今天偶然机会,翻了一下大学期间的书籍<C程序设计>,好吧,当我翻着翻着,翻到了符号常量(#define指令)中,是啊,这是一个预处理器指令,记得在Magicodes.IE中针对平台选 ...

  2. Linux应急响应--入侵排查

    1.入侵者可能会删除机器的日志信息,可以查看日志信息是否还存在或者是否被清空,相关命令示例: ll -h /var/log/*  系统日志一般都存在/var/log下常用的系统日志如下:核心启动日志: ...

  3. qmake奇淫技巧之字符串宏定义

    阅读本文大概需要3.3分钟 我们平时在软件开发过程中需要定义一些宏,以便在代码中调用,这样每次不需要修改代码,只需要修改外部编译命令就可以得到想要的参数,非常方便 比如我们想在软件介绍中显示软件版本, ...

  4. ctfhub技能树—文件上传—双写后缀

    双写后缀绕过 用于只将文件后缀名,例如"php"字符串过滤的场合: 例如:上传时将Burpsuite截获的数据包中文件名[evil.php]改为[evil.pphphp],那么过滤 ...

  5. 【九阳神功】Nessus 8_VM不限IP及AWVS破解版合体部署

    Nessus 8下载地址: https://moehu-my.sharepoint.com/personal/ximcx_moebi_org/_layouts/15/download.aspx?Sou ...

  6. 工作记录:记一次线上ZK掉线问题排查

    目录 问题的发现 zk的情况以及分析 总结 问题的发现 最早问题的发现在于用户提的,用户提出他支付时支付失败,过了一会儿再试就好了,于是翻日志,查询到当时duboo调用出现了下类错误: [TraceI ...

  7. Redis中哈希分布不均匀该怎么办

    前言 Redis 是一个键值对数据库,其键是通过哈希进行存储的.整个 Redis 可以认为是一个外层哈希,之所以称为外层哈希,是因为 Redis 内部也提供了一种哈希类型,这个可以称之为内部哈希.当我 ...

  8. 如何创建一个Java项目

    目录 新建项目 项目信息配置 创建Java类 编译和运行 新建项目 首先双击eclipse进入到eclipse页面. 菜单"File"下的"New"里" ...

  9. 安装OpenDaylight及Openflow插件

    1. 安装 Java 和 Maven CentOS7: yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 ma ...

  10. 正向代理 forward proxy、反向代理 reverse proxy、透明代理 transparent proxy

    https://zh.wikipedia.org/wiki/反向代理 反向代理在计算机网络中是代理服务器的一种.服务器根据客户端的请求,从其关系的一组或多组后端服务器(如Web服务器)上获取资源,然后 ...