关于ios::sync_with_stdio(false)
作用就是取消同步,这样的话使用cin就和使用scanf效率相似。
但是今天在做题的时候碰到一点小问题,就是在关闭同步的时候使用scanf是交了一发代码,然后RE了(经检查scanf没有写错),而把关同步注释后就AC了
不是很理解,先记下来在研究研究
附上今天做题代码:(很水的一题即可瞎搞又可线段树)
HDU-5443
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
#define lson rt<<1, left, m
#define rson rt<<1|1, m+1, right
struct Node
{
int left, right, value;
int mid()
{
;
}
}node[N<<];
void Build(int rt, int left, int right)
{
node[rt].left = left;
node[rt].right = right;
node[rt].value = ;
if(left == right)
{
//scanf("%d", &node[rt].value);
cin>>node[rt].value;
return;
}
int m = node[rt].mid();
Build(lson);
Build(rson);
node[rt].value = max(node[rt<<].value, node[rt<<|].value);
}
int Query(int rt, int left, int right)
{
int L = node[rt].left, R = node[rt].right;
if((node[rt].left >= left) && (node[rt].right <= right))
{
return node[rt].value;
}
int m = node[rt].mid();
if(right <= m)
{
, left, right);
}
else if(left > m)
{
|, left, right);
}
else
{
, left, m), Query(rt<<|, m+, right));
}
}
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
{
int m, a, b, c;
while(n--)
{
cin>>m;
Build(, , m);
cin>>a;
while(a--)
{
cin>>b>>c;
cout<<Query(, b, c)<<endl;
}
}
}
;
}
关于ios::sync_with_stdio(false)的更多相关文章
- 关于C++中ios::sync_with_stdio(false)
粘贴自:https://blog.csdn.net/weixin_44015865/article/details/84974373 在C++中的输入和输出有两种方式,一种是scanf和printf, ...
- ios::sync_with_stdio(false)提高C++读写速度
版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:ios::sync_with_stdio(false)提高C++读写速度 本文地址:h ...
- 关于std::ios::sync_with_stdio(false)
std::ios::sync_with_stdio(false); 很多C++的初学者可能会被这个问题困扰,经常出现程序无故超时,最终发现问题处在cin和cout上,(甚至有些老oier也会被这个问题 ...
- 关于ios::sync_with_stdio(false);和 cin.tie(0)加速c++输入输出流
原文地址:http://www.hankcs.com/program/cpp/cin-tie-with-sync_with_stdio-acceleration-input-and-output.ht ...
- hdu 1754 I Hate It (线段树、单点更新)(PS:ios::sync_with_stdio(false)可以加快cin、cout的读取写出速度)
I Hate ItTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- C++输入输出流加速器,关闭同步流,ios::sync_with_stdio(false)和 cin.tie(0)
leetcode练习时,总会发现运行时间短的代码都会有类似: static int x=[](){ std::ios::sync_with_stdio(false); cin.tie(NULL); ; ...
- C++关闭同步流 ios::sync_with_stdio(false)
说明:ios::sync_with_stdio(false) 1.这句语句是用来取消cin的同步,什么叫同步呢?就是iostream的缓冲跟stdio的同步.这就是为什么cin和cout比scanf和 ...
- std:ios:sync_with_stdio (false)以及局限性
如何在输入输出上提高一下效率emmmm #include<iostream> #include<stdio.h> #include<stdlib.h> #inclu ...
- std::ios::sync_with_stdio(false);
这句语句是用来取消cin的同步,什么叫同步呢?就是iostream的缓冲跟stdio的同步.如果你已经在头文件上用了using namespace std;那么就可以去掉前面的std::了.取消后就c ...
随机推荐
- linux命令后台执行
fg.bg.jobs.&.nohup.ctrl+z.ctrl+c 命令 一.& 加在一个命令的最后,可以把这个命令放到后台执行,如 watch -n 10 sh test.sh &am ...
- OpenCV中phase函数计算方向场
一.函数原型 该函数参数angleInDegrees默认为false,即弧度,当置为true时,则输出为角度. phase函数根据函数来计算角度,计算精度大约为0.3弧度,当x,y相等时,angle ...
- BotVS开发基础—2.5 策略交互
一.代码部分 isOpen = False; # 是否 开仓 price = 0; # 全局变量 价格 amount = 0; # 全局变量 下单量 def exec_command(command) ...
- [js高手之路]设计模式系列课程-委托模式实战微博发布功能
在实际开发中,经常需要为Dom元素绑定事件,如果页面上有4个li元素,点击对应的li,弹出对应的li内容,怎么做呢?是不是很简单? 大多数人的做法都是:获取元素,绑定事件 <ul> < ...
- [2017-08-28]Abp系列——业务异常与错误码设计及提示语的本地化
本系列目录:Abp介绍和经验分享-目录 前言 ABP中有个异常UserFriendlyException经常被使用,但是它所在的命名空间是Abp.UI,总觉得和展现层联系过于紧密,在AppServic ...
- python 三级联动
china_map ={ "华南":{ "广东":["广州市","佛山市","深圳市", ...
- switch case异常处理机制
public class T3{ public static void main(String[] args) { try{ String kc=""; System.out.pr ...
- MySQL的JOIN(二):JOIN原理
表连接算法 Nested Loop Join(NLJ)算法: 首先介绍一种基础算法:NLJ,嵌套循环算法.循环外层是驱动表,循坏内层是被驱动表.驱动表会驱动被驱动表进行连接操作.首先驱动表找到第一条记 ...
- vue 父子组件传参
父向子组件传参 例子:App.vue为父,引入componetA组件之后,则可以在template中使用标签(注意驼峰写法要改成componet-a写法,因为html对大小写不敏感,component ...
- 关于SpringMVC项目报错:java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/xxxx.xml]
关于SpringMVC项目报错:java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/xxxx ...