文章目录
1. OJ是什么
OJ是Online Judge系统的简称,用来在线检测程序源代码的正确性。
原本我们检测程序的正确性,都需要给别人看或是一个一个输入,有了OJ,我们就可以省去繁琐的步骤,只需轻轻一点,1秒就可以出结果,是不是非常方便?
2. OJ的各种提示
在提交时,我们会发现OJ会给我们各种提示,那么它们是什么意思呢?一起来看一看吧:
2.1 CE
C
E
(
C
o
m
p
i
l
e
E
r
r
o
r
)
CE(Compile Error)
CE(CompileError): 无法编译您的源代码,点击链接查看编译器的输出。
如下这一段代码,我们将头文件打错了(
u
o
s
t
r
e
a
m
uostream
uostream),所以会造成编译错误。
#include <uostream>
using namespace std;
int main(){
cout << "Hello, world!\n";
return 0;
}
2.2 PA
P
A
(
P
a
r
t
i
a
l
A
c
c
e
p
t
e
d
)
PA(Partial Accepted)
PA(PartialAccepted) : 加油!您提交的代码通过了部分测试点,请考虑其他可能性。
如下这一段代码,我们没有考虑全部情况(
a
a
a和
b
b
b可能是大于
i
n
t
int
int范围的正整数,所以要使用
l
o
n
g
l
o
n
g
long long
longlong),所以只通过了部分测试点。
#include<bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int a, b;
cin >> a >> b;
cout << a + b;
return 0;
}
2.3 AC
A c c e p t e d Accepted Accepted : 恭喜! 您的解题方法是正确的。
2.4 WA
W
r
o
n
g
A
n
s
w
e
r
Wrong Answer
WrongAnswer : 您的程序输出结果与判题程序的答案不符。
如下这一段代码,我们输出错误(应该输出
H
e
l
l
o
,
Hello,
Hello,
w
o
r
l
d
!
world!
world!),所以造成了答案错误。
#include<bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cout << "hello, world!";
return 0;
}
2.5 RE
R u n t i m e E r r o r Runtime Error RuntimeError : 您的程序异常终止,可能的原因是:段错误,被零除或用非0的代码退出程序。
2.6 TLE
T
i
m
e
L
i
m
i
t
E
x
c
e
e
d
e
d
Time Limit Exceeded
TimeLimitExceeded : 您的程序运行时间已超出题目限制。
这可能时使用过多循环导致的,如下这段代码,我们可以进行优化。
#include <bits/stdc++.h>
using namespace std;
signed main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
if (i % 2 == 0){
continue;
}else{
cout << i << " ";
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
signed main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i += 2)
{
cout << i << " ";
}
return 0;
}
2.7 MLE
M
e
m
o
r
y
L
i
m
i
t
E
x
c
e
e
d
e
d
Memory Limit Exceeded
MemoryLimitExceeded : 您的程序实际使用的内存已超出题目限制。
这可能是我们数组的空间开的过大导致的。
3. 国内外的OJ推荐
好的OJ也必不可少,下面给大家推荐几个OJ。
3.1 洛谷
洛谷可谓经典中的经典,大家应该都听说过。
3.2 CodeForces
CodeForces是很老的OJ,有海量题库和高质量的比赛,就是英文较多(洛谷的Remote Judge实在是不太好用)。
3.3 AtCoder
日本OJ,还是不错的。
3.4 AcWing
国内经典OJ,也很不错。
3.5 LukeLabs
国内新型OJ,比较小众,但是题目质量还是可以的。
4. 结语
今天的内容就到这里啦,三连必回qwq!