OJ相关的注意事项

it2025-07-23  9

引入STL

#include<bits/stdc++.h> // 考试万能头文件

正负无穷

int: INT_MAX/INT_MIN double: DBL_MAX/-DBL_MAX

输入输出

题目指定测试数据组数时: while(T–)

题目未指定输入长度时: while(cin >> a) , 注意cin以空格或回车作为分隔符

读入不确定行数的字符串,以空行作为结束:

vector<string> sv; string s; while(getline(cin, s)){ if(s.empty()) break; sv.emplace_back(move(s)); }

读入带分隔符的字符串:

string s; getline(cin, s); istringstream iss(s); vector<string> sv; while(getline(iss, s, ',')) // 用 while(iss >> s) 是不行的 sv.emplace_back(move(s));

数据规模

数据类型

int 型: 1 ≤ N ≤ 1 0 9 1 \le N \le 10^9 1N109

long long 型: 1 0 9 ≤ N ≤ 1 0 18 10^9 \le N \le 10^{18} 109N1018

浮点一律使用 double

时间复杂度

O ( n 2 ) O(n^2) O(n2) 算法只能用于 N ≤ 1000 N \le 1000 N1000 规模的数据,超过 1 0 4 10^4 104 必须改为 O ( n ) O(n) O(n) 或更优的算法.

空间复杂度: 数组一般不能超过 1 0 6 10^6 106

最新回复(0)