社区讨论
求助:本题洛谷IDE可以通过,OJ不能通过
P3952[NOIP 2017 提高组] 时间复杂度参与者 1已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mi7y24dz
- 此快照首次捕获于
- 2025/11/21 05:29 4 个月前
- 此快照最后确认于
- 2025/11/21 05:29 4 个月前
在洛谷IDE上测例题和第一个测试点全部没问题。
用OJ测就是11个WA。
其中第一个例题,我用IDE测是YNNN,用OJ测输出第一个字母是N,直接错了。
所以请教下IDE和OJ输出是否有出入
如果没问题,恳请大大帮我测试一下程序问题出在哪
#include
#include
#include
using std::stack;
using std::string;
using std::cin;
using std::cout;
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
int line, On;
int alpha[26] = { 0 };
string s;
stack si;
bool err = false, Y = false, N = true;
cin >> line;
getline(cin, s);
if (s[3] == '1')
{
On = 0;
Y = true;
}
else On = s[5] - '0';
for (int j = 0; j < line; j++)
{
getline(cin, s);
if (s[0] == 'F')
{
int ch = s[2] - 'a';
if (alpha[ch]++ == 1)
{
err = true;
break;
}
if (s[4] != 'n'&&*(s.end() - 2) == 'n' && (si.empty() || si.top() != 'n'))
{
On--;
if (On == 0) Y = true;
if (On == -1) N = false;
si.push(ch);
}
else si.push('n');
}
if (s[0] == 'E')
{
if (si.empty())
{
err = true;
break;
}
alpha[si.top()]--;
if (si.top() != 'n')
On++;
si.pop();
}
}
if (err || !si.empty())
cout << "ERR\n";
else if (Y && N) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...