关于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 ...
随机推荐
- Notepad++使用图解
Notepad++使用图解.. Notepad++的安装部分 -------------- -------------- --------------- -------------- -------- ...
- 8.8.2 Final关键字
final表示不可改变的含义 1.采用final 修饰的类不能被继承 2.采用final 修饰的方法不能被覆盖 3.采用final 修饰的变量不能被修改 4.final修饰的变量必须显示初始化(该 ...
- 7.21.01 if语句
if语句 一个if语句包含一个布尔表达式和一条或多条语句. 语法 if语句的用语法如下: if(布尔表达式) { //如果布尔表达式为true将执行的语句 } 如果布尔表达式的值为true,则执行if ...
- latex插图续
LaTeX中一般只直接支持插入eps(Encapsulated PostScript)格式的图形文件, 因此在图片插入latex文档之前应先设法得到图片的eps格式的文件. UNIX下的各种应用软件 ...
- python+selenium自动化软件测试(第6章):selenium phantomjs页面解析使用
我们都知道Selenium是一个Web的自动化测试工具,可以在多平台下操作多种浏览器进行各种动作,比如运行浏览器,访问页面,点击按钮,提交表单,浏览器窗口调整,鼠标右键和拖放动作,下拉框和对话框处理等 ...
- 以太坊系列之十六: 使用golang与智能合约进行交互
以太坊系列之十六: 使用golang与智能合约进行交互 以太坊系列之十六: 使用golang与智能合约进行交互 此例子的目录结构 token contract 智能合约的golang wrapper ...
- hdu 6107--Typesetting(倍增)
题目链接 Problem Description Yellowstar is writing an article that contains N words and 1 picture, and t ...
- Java虚拟机基础
Java虚拟机基础 JVM是Java Virtual Machine的缩写.JVM是一个可以将Java字节码转换成机器语言并能被机器(电脑)执行的Java字节码处理引擎.Java字节码是处于Java和 ...
- js中bind、call、apply函数的用法 (转载)
最近看了一篇不错的有关js的文章,转载过来收藏先!!! 最近一直在用 js 写游戏服务器,我也接触 js 时间不长,大学的时候用 js 做过一个 H3C 的 web 的项目,然后在腾讯实习的时候用 j ...
- 关于用VMware克隆linux系统后,无法联网找不到eth0网卡的问题
当使用克隆后的虚拟机时发现系统中的网卡eth0没有了,使用ifconfig -a会发现只有eth1.因为系统是克隆过来的,原有的eth0以及ip地址都是原先网卡的,VMware发现已经被占用,就会创建 ...