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.pswp.cn/news/541775.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541775.shtml
英文地址,請注明出處:http://en.pswp.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…