c++中tle是什么意思_如何在竞争性编程中克服TLE?

c++中tle是什么意思

什么是TLE? (What is TLE?)

TLE means "Time Limit Exceed". So, in competitive programming, there are some constraints with a specific time limit (normally for each input 1 sec) and your task is to write your code in such a way that all test cases are passed within that time limit for each input.

TLE的意思是“超过时间限制” 。 因此,在竞争性编程中,存在一些特定时间限制的约束(通常每个输入1秒钟),您的任务是编写代码,使所有测试用例均在该时间限制内通过每个输入。

If it does not, then obviously you will get TLE (if there is no compiler or runtime error).

如果没有,那么显然您将获得TLE (如果没有编译器或运行时错误)。

The main problem in TLE is, you will not be able to know whether your code is generating the right output or not.

TLE中的主要问题是,您将无法知道代码是否生成正确的输出。

Because they first check your compiler error (if any) then runtime error (if any), then TLE (if any) and at last right or wrong answer your code is generating.

因为他们首先检查您的编译器错误(如果有),然后是运行时错误(如果有),然后是TLE (如果有),最后是您生成的代码的正确或错误答案。

为什么TLE来? (Why TLE comes?)

There might be various reasons behind it that your TLE is coming. Some of the important reasons are:

TLE即将到来可能有多种原因。 一些重要的原因是:

1) Online Judge:

1)在线评委:

This is the main reason you can say. An online judge ( like codechef, hackerrank , hackerearth, etc) gives TLE on a question because there are some restrictions in each input with a specific time limit. If your program exceeds that time limit you will get TLE.

这是您可以说的主要原因。 一位在线法官(例如codechef,hackerrank,hackerearth等)对TLE进行提问,因为每个输入都有特定的时间限制。 如果您的程序超过了该时间限制,您将获得TLE。

2) Reading input and output slowly:

2)缓慢读取输入和输出:

Sometimes your code takes input slowly ( though you are responsible for that:). However, if you use Fast Input-Output method (FastIO) your program always runs faster.

有时,您的代码输入很慢(尽管您对此负责)。 但是,如果您使用快速输入输出方法(FastIO),则程序始终会运行得更快。

To add fast IO in your code you have to write the following lines in main() in your code:

要在代码中添加快速IO,您必须在代码的main()中编写以下几行:

C / C++

C / C ++

    ios_base::sync_with_stdio(false); 
cin.tie(NULL) ;

Python

Python

    import psyco
psyco.full()

Java Do not use Scanner class, use BufferedReader instead.

Java不要使用Scanner类,而应使用BufferedReader 。

3) Server Configuration

3)服务器配置

Sometimes, the server takes time to run your code. So, it might depend on their CPU, OS, etc. For this reason, the different platform gives you TLE in different cases.

有时,服务器需要一些时间来运行您的代码。 因此,这可能取决于其CPU,操作系统等。因此,不同的平台会在不同情况下为您提供TLE。

4) Bound of loops

4)循环界限

This is one of the main reason for competitive programming for getting TLE.

这是获得TLE竞争性编程的主要原因之一。

Suppose you are given a time limit of 1 sec for a value N. So you can run a loop at max range 10^7. Below table defines the complexity and value of N what should be for a time limit of 1 sec:

假设您为N设置了1秒的时间限制。因此,您可以在最大范围10 ^ 7处运行循环。 下表定义了N的复杂度和值,在1秒的时间限制内应该是:

Max value of NSuggested Max Complexity to overcome TLE
10^2O(N^3)
10^3O(N^2)
10^5O(N * log (N))
10^6O(N) [Perfectly accepted]
10^7O(N) [ Use FastIO]
10^8O(N) [ Border case ]
10^9log (N) or sqrt(N)
N的最大值 建议的最大复杂度以克服TLE
10 ^ 2 O(N ^ 3)
10 ^ 3 O(N ^ 2)
10 ^ 5 O(N *对数(N))
10 ^ 6 O(N)[完全接受]
10 ^ 7 O(N)[使用FastIO]
10 ^ 8 O(N)[边境案件]
10 ^ 9 对数(N)或sqrt(N)

Please Note that, a loop value (N) cannot be greater than 10^9 if N is an integer. Because an integer can take up to 10^9.

请注意,如果N为整数,则循环值(N)不能大于10 ^ 9。 因为整数最多可以占用10 ^ 9。

So, if you get TLE in any question always refer to the above table and try to optimize your solution. A program can be done in various ways and using various algorithms. Also always use FastIO for each problem you are solving.

因此,如果您在任何问题上都获得TLE,请始终参考上表并尝试优化您的解决方案。 可以通过各种方式和使用各种算法来完成程序。 对于要解决的每个问题,也请始终使用FastIO。

All the best for your coding life.

祝您编程生活一切顺利。

翻译自: https://www.includehelp.com/icp/how-to-overcome-tle-in-competitive-programming.aspx

c++中tle是什么意思

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

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

相关文章

美颜相机window 开源_X-Window系统| 免费和开源软件

美颜相机window 开源X窗口系统 (The X-Window System) The X-Window System is a GUI that sits over Linux. Not at all like Microsoft Windows, the X Window System can glance and work in an enormously wide range of ways. It can work smoothly or lag, look excellen…

php 代码 自动检查工具下载,PHP_CodeSniffer安装和使用教程(自动代码检查规范工具)...

在我们开发中都会讲究代码规范,若是个人开发者,代码规范与否,只要自己看得懂便可以了,但是在团队协作中,代码规定尤为重要,下面,我们介绍一款PHP_CodeSniffer,自动检查代码规范的工具…

国际象棋之跳马程序

问题描述: 假设国际象棋棋盘有5*5共25个格子。设计一个程序,使棋子从初始位置(棋盘格编号为1的位置)开始跳马,能够把棋盘的格子全部走一遍,每个格子只允许走一次。要求: 1) 输出一个解(用二维数组来记录马跳的过程,即[步号,棋盘格编号],左上角为第一步起点)&#xf…

kafka安装使用

版本:kafka_2.11-0.10.1.0 (之前安装2.10-0.10.0.0,一直出问题) 安装Springboot结合Kafka的使用安装 下载并解压代码 wget http://mirrors.cnnic.cn/apache/kafka/0.10.0.0/kafka_2.10-0.10.0.0.tgz #http://kafka.apache.org/downloadstar -zxvf kafka…

php获取上传文件路径 fakepath,JavaScript_js获取上传文件的绝对路径实现方法,在html中input type=file - phpStudy...

js获取上传文件的绝对路径实现方法在html中function upload() {var filename document.getElementById("importFile").value;// 这时的filename不是 importFile 框中的值alert(filename);}如上面的代码,用文件上传对话框选择文件后,如果选择&…

在Bootstrap中使用类的按钮类型

Bootstrap has 7 different types of buttons with contextual classes from which we can create buttons easily by using these classes (.btn-default, .btn-success, .btn-danger, .btn-primary, .btn-info, .btn-warning, .btn-link). Bootstrap具有上下文类型的 7种不同…

php json encode中文乱码,php json_encode中文乱码如何解决

php encode中文乱码的解决办法:首先打开相应的PHP文件;然后使用正则语句“preg_replace("#\\\u([0-9a-f]{4})#ie","iconv(UCS-2BE, UTF-8...)”将编码替换成中文即可。本文列举3个方法,实现json_encode()后的string显示中文问…

乡村图景(转载)

转自: http://cul.qq.com/a/20160205/046437.htm 我丈夫家在湖北孝感孝昌县的一个村子。2005年第一次过年回到他家,印象最深的就是嫂子。我暗自问当时的男友,“哥哥尽管算不上特别帅气,但为何找了这么难看的嫂子?”后来才发现&…

stl向量最大值_C ++ STL中向量的最小和最大元素

stl向量最大值Given a vector and we have to find the smallest (minimum) and largest (maximum) elements. 给定一个向量,我们必须找到最小(最小)和最大(最大)元素。 查找向量的最小和最大元素 (Finding vectors minimum & maximum elements) To find minim…

oracle如何设置备份计划任务,Oracle数据库设置任务计划备份一周的备份记录

Oracle 数据库备份:--保留最近一周的备份记录;正文:开始代码如下:echo 设置备份文件存放文件夹...set "tbufE:\Cway\backup"echo 设置备份文件名(以星期几命名,即备份文件只保存最近一周)...set name%date%set name%nam…

索引(转载自百度百科)

Oracle索引 编辑本词条缺少信息栏、名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧!在oracle索引是一种供服务器在表中快速查找一个行的数据库结构。合理使用索引能够大大提高数据库的运行效率。目录 1 概念及作用 2…

阿姆斯特朗数_阿姆斯特朗的功能依赖公理 数据库管理系统

阿姆斯特朗数Armstrong axioms are a complete set of inference rules or axioms, introduced and developed by William W. Armstrong in 1974. The inference rules are sound which is used to test logical inferences of functional dependencies. The axiom which also …

ORACLE JOB 失败 查看,Oracle JOB异常中断原因分析

注释今天研发同事找我确认 PKG_WMS.proc_TaskMain 存储的 job 是否还在运行,竟发现 dba_jobs.NEXT_DATE4000/1/1,如下看看究竟原因吧~JOB 信息:参数:BROKEN : 中断标记 ,N 启动、Y 中断 --> DBMS_JOBS.BROKEN(job_id,TRUE/FA…

ruby打印_Ruby程序打印一个数字的乘法表

ruby打印打印乘法表 (Printing multiplication table) This requires a very simple logic where we only have to multiply the number with digits from 1 to 10. This can be implemented by putting the multiplication statement inside a loop. We have mentioned two wa…

步骤1:JMeter 录制脚本接口测试

JMeter 常用测试方法简介 1.下载安装 http://jmeter.apache.org/download_jmeter.cgi 安装JDK,配置环境变量JAVA_HOME. 系统要求:JMeter2.11 需要JDK1.6以上的版本支持运行 2.学习Jmeter元件 http://jmeter.apache.org/usermanual/component_reference.h…

模拟断电oracle数据不一致,Oracle数据库案例整理-Oracle系统运行时故障-断电导致数据文件状态变为RECOVER...

1.1 现象描述异常断电,数据库数据文件的状态由ONLINE变为RECOVER。系统显示如下信息:SQL> select file_name ,tablespace_name ,online_status from dba_data_files;FILE_NAME---------------------------------------------------------------…

python日历模块_Python日历模块| prmonth()方法与示例

python日历模块Python calendar.prmonth()方法 (Python calendar.prmonth() Method) prmonth() method is an inbuilt method of the calendar module in Python. It works on simple text calendars and prints the calendar of the given month of the given year. Also, the…

多例模式

多例:只是单例的一种延伸 不必过于在意各种模式的名字,重要的是学会融会贯通,把生产的car放到集合中 类似JDBC 的连接池 把连接对象放到池中 多例模式特点: 1. 多例类可以有多个实例 2. 多例类必须自己创建自己的实例&a…

Oracle public view,【易错概念】以太坊Solidity函数的external/internal,public/private,view/pure/payable区别...

1. 函数类型:内部(internal)函数和外部(external)函数函数类型是一种表示函数的类型。可以将一个函数赋值给另一个函数类型的变量,也可以将一个函数作为参数进行传递,还能在函数调用中返回函数类型变量。 函数类型有两类:- 内部(i…

c-style字符字符串_C字符串-能力问题与解答

c-style字符字符串C programming String Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on Strings, String is the set of characters and String related Aptitude Questions and Answers you will find here. C编程Stri…