Codeforces Round #736 (Div. 2)(B-C)

Codeforces Round #736 (Div. 2)
花了十分钟帮朋友写了B,C就睡觉了,自己没打

B
先看上,再看左后看右

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
signed main()
{int t;cin>>t;while (t--){int n;cin>>n;string str1,str2;cin>>str1;cin>>str2;int cou = 0;for (int i=0;i<n;i++){if (str2[i]=='1'){if (str1[i]=='0') {cou++;str1[i] = '2';}else{if (i==n-1) {if (str1[i-1]=='1') {cou++;str1[i-1] = '2';}}else if (i==0){if (str1[i+1]=='1') {cou++;str1[i+1] = '2';}}else{if (str1[i-1]=='1') {cou++;str1[i-1] = '2';}else if (str1[i+1]=='1') {cou++;str1[i+1] = '2';}}}}}cout<<cou<<endl;}
}

C
对于一个贵族来说,如果他连接了比他高级的贵族,那就死翘翘了。没有就活着

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
int flag[500100];
signed main()
{int n,m;cin>>n>>m;int a,b;memset(flag,0,sizeof(flag));int cou = 0;for (int i=0;i<m;i++){cin>>a>>b;int A = min(a,b);// int B = max(a,b);flag[A] ++;if (flag[A]==1) cou++;}int q;cin>>q;int h,u,v;while (q--){cin>>a;if (a==1) {cin>>u>>v;int A = min(u,v);flag[A]++;if (flag[A]==1) cou++;}else if (a==2){cin>>u>>v;int A = min(u,v);flag[A]--;if (flag[A]==0) cou--;}else if (a==3){cout<<n-cou<<endl;}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/428730.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

RabbitMQ 声明Queue时的参数们的Power

RabbitMQ 声明Queue时的参数们的Power 参数们的Power 在声明队列的时候会有很多的参数 public static QueueDeclareOk QueueDeclare(this IModel model, string queue "", bool durable false, bool exclusive true, bool autoDelete true, IDictionary<strin…

解决Firefox已阻止运行早期版本Adobe Flash

解决Firefox已阻止运行早期版本Adobe Flash 类别 [随笔分类]web 解决Firefox已阻止运行早期版本Adobe Flash 最近火狐浏览器不知抽什么风&#xff0c;每次打开总提示"Firefox已阻止(null)运行早期版本的Adobe Flash"。要命的是它提示的解决办法根本不管用&#xf…

误删path怎么办(已重启)

我是在设置环境变量的时候不懂&#xff0c;新建了一个path&#xff0c;导致我原来的path没了。 但是居然jdk能用。。。。。不太懂。 不要慌&#xff0c;大不了重装系统。其实只要再重新新建就行了。 C:\Program Files\Common Files\Siemens\Automation\Simatic OAM\bin;%Syste…

一个容易被忽视的css选择器

之前学的的迷糊了&#xff0c;也不知道什么会什么不会了&#xff0c;跑去面试了。别人列出一堆css选择器&#xff0c;本以为选择器没啥的&#xff0c;结果到那个多类选择器翻车了&#xff0c;.a.b选择同时含a,b类名的&#xff0c;很尴尬所以回来仔细整理了一下。目前根据W3C手册…

Codeforces Round #756 (Div. 3)

Codeforces Round #756 (Div. 3) A. Make Even 思路&#xff1a;如果末尾是偶数&#xff0c;不需要操作&#xff1b;如果开头是偶数&#xff0c;一次操作&#xff0c;即全翻转&#xff1b;如果开头和末尾都是 奇数&#xff0c;判断里面是否有偶数&#xff0c;如果没有&#xff…

使用MyBatista----上传图像

使用MyBatis上传图像&#xff0c;使用的是Oracle的数据库表&#xff0c;有一个TEACHER表&#xff0c;有7列&#xff0c;有1列是存储图片的&#xff0c;类型用BLOB&#xff0c;最大容量是4G&#xff0c;以二进制的形式写入数据库表。 建立这个表的对应实体类Teacher&#xff0c;…

189A. Cut Ribbon

A. Cut Ribbon:题目地址 题意&#xff1a;一条长为n的彩带切割&#xff0c;切割后每段长度是a或者是b或者是c#include <bits/stdc.h> using namespace std; typedef long long ll; vector<int> a((int)4e5); vector<int> b((int)4e5); int main() {int n,a,…

作业1.3

public class Work{   public static void main(String[] args)   {     System.out.println(" J A V V A");     System.out.println(" J A A V V A A"); //直接输出就好了     System.out.println("J J …

476B. Dreamoon and WiFi

B. Dreamoon and WiFi:题目链接 题意&#xff1a;给你一个正常的走向&#xff0c;在给你一个虚假和不确定的走向&#xff0c;问到达的可能性#include <bits/stdc.h> using namespace std; string str1, str2; double C(double A, double B) {double res 1.0;for (int i…

简易观察者模式

var Event {   on(event,callback){     if(!this.handles){       this.handles {};     }     if(!this.handles[event]){       this.handles[event] [];     }     this.handles[event].push(callback);   },   emit(event){   …

1360E. Polygon

E. Polygon&#xff1a;题目 题意&#xff1a;在一个n*n的方块空间内&#xff0c;上下都有大炮&#xff0c;发射数量和先后由你决定。问能否得到他给的地图。 思路&#xff1a;如果他不是靠下边或者右边&#xff0c;右或者下必有一个炮弹阻挡。所以直接遍历判断就行#include &…

1470A. Strange Birthday Party

A. Strange Birthday Party&#xff1a;题目 题意&#xff1a;有n个朋友&#xff0c;要么给他钱&#xff0c;要么给他买礼物&#xff0c;礼物每样只能买一个 思路&#xff1a;sort&#xff0c;给钱不如给礼物的给礼物&#xff0c;礼物给完了&#xff0c;或者礼物本身太贵不如给…

_INTSIZEOF

在_INTSIZEOF中该有的都有了 1.这其中最小非负剩余和最大正余数例子如下: 设n为4&#xff0c;当r为1时&#xff0c;最小非负剩余就是1&#xff0c;最大非正剩余就是1 - 4 -3&#xff0c;最大正余数为4 - 1 3 2.x nq r推导出qn ((x n - 1) / n) * n的过程如下 1)当x % n等…

Windows下struct和union字节对齐设置以及大小的确定(一 简介和结构体大小的确定)...

在windows下设置字节对齐大小的方式&#xff0c;目前我了解有三种&#xff1a; 1. 在编译程序时候的编译选项 /Zp[n]&#xff0c;如 cl /Zp4 表示对齐大小是4字节&#xff1b; 2. 预处理命令 #pragma pack( [ show ] | [ push | pop ] [, identifier ] , n )&#xff1b; 3…

1285B. Just Eat It

B. Just Eat It!&#xff1a;题目 题意&#xff1a;全部吃是否绝对比吃一部分好 思路&#xff0c;如果一部分总和是0或者负的&#xff0c;就可以通过吃另一部分大于等于全吃。#include <bits/stdc.h> using namespace std; typedef long long ll; vector<int> a((…

小米手机无法连上WIFI网络的解决方案

最近很多朋友提问&#xff0c;为什么自己的小米手机无法连上WIFI网络&#xff0c;这里本人就此问题&#xff0c;教大家如何解决故障&#xff1a;1.首先给大家看看故障现象&#xff1a;故障说明&#xff1a;虽然手机上已经打开WLAN&#xff0c;但是当手机连接无线路由器的时候&a…

1037C. Equalize

C. Equalize&#xff1a;题目 题意&#xff1a;a字符串变成b字符串&#xff0c;有两种方法&#xff0c;一种是选两个换位置&#xff0c;花费为abs[j-i]&#xff0c;二是单独一个变,花费为1。 思路&#xff1a;如果两个需要变并且不一样挨在一起就可以省一点花费。#include <…

bzoj1051[kosaraju算法]求强连通分量

之前一直用的是tarjan第一次学习到这个来试一下。 唔&#xff0c;就是裸的算法&#xff0c;然后如果出度为0的点只有一个&#xff0c;输出这个点的大小。 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<que…

1555C. Coin Rows

C. Coin Rows&#xff1a;题目 题意&#xff1a;仿佛是一道难的dp&#xff0c;但是因为Alice先走&#xff0c;走完bob想要最大化收益。 Alice走完后Bob要么一直往右走&#xff0c;要么一开始就下去然后往右走。#include <bits/stdc.h> using namespace std; #define int…

常见sql技巧

一、一些常见的SQL实践 &#xff08;1&#xff09;负向条件查询不能使用索引 select * from order where status!0 and stauts!1 not in/not exists都不是好习惯 可以优化为in查询&#xff1a; select * from order where status in(2,3) &#xff08;2&#xff09;前导模糊查询…