F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:注册本OJ方式请见https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671 2:请不要在讨论区中发空白主题帖。
大视野在线测评-欢迎您
[ New Thread ]
Problem 2761 >> Presentation_Error
yzk @ 2012-12-19 19:13:28
[ Quote ] [ Edit ] [ Delete ] 1#
莫名Presentation_Error
原先同学A的程序,也是PE了。
什么情况?
Alextokc @ 2017-07-12 02:37:09
[ Quote ] [ Edit ] [ Delete ] 2#
我的也pe了。。
#include <iostream>
#include <cstdio>
#include <map>
//#include <unordered_map>

using namespace std;

int main() {
ios::sync_with_stdio(false);

int T;
scanf("%d", &T);//cin >> T;

map < int, int > nums;

while (T--) {
nums.clear();
int n; scanf("%d", &n);//cin >> n;
int x, i;
for (i = 1; i <= n; ++i) {
scanf("%d", &x);//cin >> x;
if (nums[x] != -1) {
printf("%d ", x);//cout << x << ' ';
nums[x] = -1;
}
}
//cout << endl;
printf("\n");
}

return 0;
}
Alextokc @ 2017-07-12 02:51:12
[ Quote ] [ Edit ] [ Delete ] 3#
以下代码ac:
#include <iostream>
#include <cstdio>
#include <map>
//#include <unordered_map>

using namespace std;

int main() {
ios::sync_with_stdio(false);

int T;
scanf("%d", &T);//cin >> T;

map < int, int > nums;

while (T--) {
nums.clear();
int n; scanf("%d", &n);//cin >> n;
int x, i;
scanf("%d", &x);printf("%d", x);
nums[x] = -1;
for (i = 2; i <= n; ++i) {
scanf("%d", &x);//cin >> x;
if (nums[x] != -1) {
printf(" %d", x);//cout << x << ' ';
nums[x] = -1;
}
}
printf("\n");
//cout << endl;
//cout << endl;
//printf("\n");
}

return 0;
}
Alextokc @ 2017-07-12 02:52:00
[ Quote ] [ Edit ] [ Delete ] 4#
我的提交:
http://www.lydsy.com/JudgeOnline/status.php?problem_id=2761&user_id=Alextokc&language=-1&jresult=-1
Alextokc @ 2017-07-12 02:54:43
[ Quote ] [ Edit ] [ Delete ] 5#
提交了许多次,最后得出的是:
1.写这题不能用o(n)的unordered_map,bzoj好像不支持c++11,否则会ce
2.写这题不能用cin, cout,否则会re
3.写这题的行末不能输出空格,否则会pe
4.写这题如果cin,cout,scanf,printf混用的话可能会导致re或wa
RyeCatcher @ 2018-07-15 17:41:28
[ Quote ] [ Edit ] [ Delete ] 6#
BZOJ 可以开unordered_map 但要加这些

#include <tr1/unordeded_map>
using namespace std::tr1;
zengzihang @ 2018-10-04 20:57:44
[ Quote ] [ Edit ] [ Delete ] 7#
认同楼上
[Top] [Previous Page] [Next Page]

HOME Back