关于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 ...
随机推荐
- 基本元件库(Basic)
- spring MVC处理请求过程及配置详解
本文主要梳理下Spring MVC处理http请求的过程,以及配置servlet及业务application需要的常用标签,及其包含的意义. spring MVC处理请求过程 首先看一个整体图 简单说 ...
- wpf创建用户控件(计时器控件)
在vs中新增用户控件 前台xaml如下代码: <UserControl x:Class="Zh.SelfServiceEquipment.UI.ZhControls.CountDown ...
- mysql中group by 的用法解析
1. group by的常规用法 group by的常规用法是配合聚合函数,利用分组信息进行统计,常见的是配合max等聚合函数筛选数据后分析,以及配合having进行筛选后过滤. 假设现有数据库表如下 ...
- C++中4个类型转换相关的关键字/特点/应用场合
reinterpret_cast是C++里面的一个强制类型转换符,能够将任何的指针类型转换成其他的任何指针类型:能够将任何的整数类型转换成指针类型,反之亦然:滥用reinterpret_cast强制类 ...
- html5 响应式布局(媒体查询)
响应式布局 响应式布局,简而言之,就是一个网站能够兼容多个终端--而不是为每个终端做一个特定的版本.这个概念是为解决移动互联网浏览而诞生的. 响应式布局可以为不同终端的用户 ...
- JSON、数组、时间戳
// on removeClass addClass slice $('.pic-subgroup').on('click',function(){ $('.pic_div.active').remo ...
- Java中 Comparator接口 与Comparable 的区别
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt159 comparator接口与Comparable接口的区别 1. Com ...
- String.equals()方法
public boolean equals(Object anObject) { if (this == anObject) { return true; } ...
- 初入PHP,(for循环~水仙花数)
找出100-999之间的所有"水仙花数".所谓水仙花数是指一个三位 数,各位数字的立方和等于该数本身.(如153次方=1的3次方+5的3次方+3的3次方)并输出这些数字 想想153 ...