关于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 ...
随机推荐
- ajax和json
1.$ ajax({ url:"", data:{username:"admin"},//发送时携带的参数 type:"post/get", ...
- Linux巩固记录(3) hadoop 2.7.4 环境搭建
由于要近期使用hadoop等进行相关任务执行,操作linux时候就多了 以前只在linux上配置J2EE项目执行环境,无非配置下jdk,部署tomcat,再通过docker或者jenkins自动部署上 ...
- 数据结构之合并链表STL
#include <iostream> #include <list> using namespace std; int main() { int n, m; while (c ...
- PS软件操作应用—文字特效
前 言 JRedu 在图像调整和文字工具的分享文章中,对文字工具做了简单的介绍,包括了文字的字体.字号大小.颜色以及字间距行距等等的设置和修改,都是一些基本的功能,在这次的分享中我们介绍下文字特 ...
- 32位汇编第一讲x86和8086的区别,以及OllyDbg调试器的使用
32位汇编第一讲x86和8086的区别,以及OllyDbg调试器的使用 一丶32位(x86也称为80386)与8086(16位)汇编的区别 1.寄存器的改变 AX 变为 EAX 可以这样想,16位通 ...
- vue引入echarts、找不到的图表引入方法、图表中的点击事件
1.在vue-cli项目中添加webpack配置,本文引入的最新版本.在 3.1.1 版本之前 ECharts 在 npm 上的 package 是非官方维护的,从 3.1.1 开始由官方 EFE 维 ...
- CPU和GPU的差别
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt317 首先需要解释CPU和GPU这两个缩写分别代表什么.CPU即中央处理器, ...
- my new start
my new start in blog csdn : today i formally migrate my personal technical blog from sina to here in ...
- 201521123073《Java程序设计》第4周学习总结
一. 本周学习总结 二. 书面作业 1.注释的应用 2.面向对象设计(大作业1,非常重要) 2.1 将在网上商城购物或者在班级博客进行学习这一过程,描述成一个故事.(不得少于50字,参考QQ群中PPT ...
- 201521123086《java程序设计》第四周
本章学习总结 尝试使用思维导图总结有关继承的知识点 1.2 使用常规方法总结其他上课内容. 为了不必要写重复的代码,可以运用继承,用关键字extends来定义一个类,被继承的类叫做父类,继承的类叫做子 ...