不同编程网站应当注意的点

引入:

小伙伴们有没有遇到过这种情况:到一个新的网站去编程,思路、算法完全正确,提交上去却是 Wrong AnswerRuntime ErrorComplie ErrorTime Limit Exceed 。这里,我总结了以下几个网站的注意点:

洛谷:

link

提交时右上角有一个选项为 O2 优化。这并不可以随便选。可能有些暴力程序开了 O2 就过了,但正解代码可能厌氧,开了 O2 反而会 TLE

可能的错误点:数组开大了,ll 函数没有返回值,等等。

POJ:

link

北京大学的 OJ ,比较古老,只支持 C++98。因此,不能使用万能头 #include<bits/stdc++.h> 。需要手写头文件。

这里为了方便读者,给出了以下很多常用的头文件:

C语言:

#include <assert.h>    设定插入点
#include <ctype.h>     字符处理
#include <errno.h>     定义错误码
#include <float.h>     浮点数处理
#include <fstream.h>   文件输入/输出
#include <iomanip.h>   参数化输入/输出
#include <iostream.h>   数据流输入/输出
#include <limits.h>    定义各种数据类型最值常量
#include <locale.h>    定义本地化函数
#include <math.h>     定义数学函数
#include <stdio.h>    定义输入/输出函数
#include <stdlib.h>    定义杂项函数及内存分配函数
#include <string.h>    字符串处理
#include <strstrea.h>   基于数组的输入/输出
#include <time.h>     定义关于时间的函数
#include <wchar.h>    宽字符处理及输入/输出
#include <wctype.h>    宽字符分类

#include <assert.h>    //设定插入点
#include <ctype.h>     //字符处理
#include <errno.h>     //定义错误码
#include <float.h>     //浮点数处理
#include <fstream.h>   //文件输入/输出
#include <iomanip.h>   //参数化输入/输出
#include <iostream.h>   //数据流输入/输出
#include <limits.h>    //定义各种数据类型最值常量
#include <locale.h>    //定义本地化函数
#include <math.h>     //定义数学函数
#include <stdio.h>    //定义输入/输出函数
#include <stdlib.h>    //定义杂项函数及内存分配函数
#include <string.h>    //字符串处理
#include <strstrea.h>   //基于数组的输入/输出
#include <time.h>     //定义关于时间的函数
#include <wchar.h>    //宽字符处理及输入/输出
#include <wctype.h>    //宽字符分类
int main(){
   

}

C++:

#include < algorithm >   STL通用算法
#include < bitset >    STL位集容器
#include < cctype >
#include < cerrno >
#include < clocale >
#include < cmath >
#include < complex >   复数类
#include < cstdio >
#include < cstdlib >
#include < cstring >
#include < ctime >
#include < deque >    STL双端队列容器
#include < exception >  异常处理类
#include < fstream >
#include < functional >  STL定义运算函数(代替运算符)
#include < limits >
#include < list >     STL线性列表容器
#include < map >     STL 映射容器
#include < iomanip >
#include < ios >     基本输入/输出支持
#include < iosfwd >  输入/输出系统使用的前置声明
#include < iostream >
#include < istream >    基本输入流
#include < ostream >   基本输出流
#include < queue >    STL队列容器
#include < set >      STL 集合容器
#include < sstream >   基于字符串的流
#include < stack >    STL堆栈容器    
#include < stdexcept >   标准异常类
#include < streambuf >  底层输入/输出支持
#include < string >    字符串类
#include < utility >     STL通用模板类
#include < vector >    STL动态数组容器
#include < cwchar >
#include < cwctype >

#include <algorithm>    //STL通用算法
#include <bitset>     //STL位集容器
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>     //复数类
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>      //STL双端队列容器
#include <exception>    //异常处理类
#include <fstream>
#include <functional>   //STL定义运算函数(代替运算符)
#include <limits>
#include <list>      //STL线性列表容器
#include <map>       //STL 映射容器
#include <iomanip>
#include <ios>      //基本输入/输出支持
#include <iosfwd>     //输入/输出系统使用的前置声明
#include <iostream>
#include <istream>     //基本输入流
#include <ostream>     //基本输出流
#include <queue>      //STL队列容器
#include <set>       //STL 集合容器
#include <sstream>    //基于字符串的流
#include <stack>      //STL堆栈容器    
#include <stdexcept>    //标准异常类
#include <streambuf>   //底层输入/输出支持
#include <string>     //字符串类
#include <utility>     //STL通用模板类
#include <vector>     //STL动态数组容器
#include <cwchar>
#include <cwctype>
using namespace std;
int main(){
   

}

并且不能用 cin>>s 之类来输入一个字符串,只能用 scanf("%s",s) 来读入。

CF:

link

大部分是多组数据。

不能用 unordered_map ,建议手写 hash 或者使用常数大很多的 map

因为有 dalao 对着 unordered_map 的源码构造 hack 数据,所以 unordered_mapTLE

如果在洛谷上提交,则不能选择 C++14 ,否则会返回 UKE

而我们平时用的基本上都是 C++14 ,因此要选择 c++17 或者是 C++20 。我个人推荐 C++17 ,这是因为 C++20 当中有一些变量名其实自己是一个函数,容易 CE

个人建议:

做题的目的,是提高自己的水平,从而打比赛的时候能比较顺畅。而真正比赛的时候可以用万能头,所以我们平时可以直接复制所以的头文件。

关于 STL ,我的建议是手写,因为手写常数小,不容易被卡掉。

补充:

大家有什么补充,欢迎发在评论区~

相关推荐

  1. 不同编程网站应当注意

    2024-02-19 05:44:01       31 阅读
  2. 电子商务类网站搭建需要注意

    2024-02-19 05:44:01       20 阅读
  3. MySQL唯一索引失效注意

    2024-02-19 05:44:01       30 阅读
  4. SpringMVC- ThreadLocal变量注意

    2024-02-19 05:44:01       31 阅读
  5. tensorflow list_files需要注意

    2024-02-19 05:44:01       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-19 05:44:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-19 05:44:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-19 05:44:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-19 05:44:01       20 阅读

热门阅读

  1. C++入门

    C++入门

    2024-02-19 05:44:01      28 阅读
  2. 从零开始学HCIA之广域网技术01

    2024-02-19 05:44:01       27 阅读
  3. Deep深度系统下载安装Beyond compare4

    2024-02-19 05:44:01       32 阅读
  4. vivado Multipliers

    2024-02-19 05:44:01       26 阅读
  5. Leetcode刷题(三十三)

    2024-02-19 05:44:01       25 阅读
  6. C语言猜数字小游戏智能版

    2024-02-19 05:44:01       33 阅读