社区讨论
捞+求助:Nothing is compiled: OUTPUT exceeds
学术版参与者 3已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @m2fncrqx
- 此快照首次捕获于
- 2024/10/19 12:16 去年
- 此快照最后确认于
- 2025/11/04 16:51 4 个月前
RT 求调.
提交 P11186 遇到了如下报错:
CPPCompile Error
Nothing is compiled: OUTPUT exceeds
代码:
编程语言
C++14 (GCC 9) O2
CPP//
#include <bits/stdc++.h>
using namespace std;
const int maxn=500010;
struct Node{
bool islv=1,flag=0;
int l=-1,r=-1,val=-1;
}trees[maxn];
int m,q,treecnt=1;
string s;
int tmp=0;//到哪儿了?? imp
int get_a_num(){
//cout<<"getnm "<<x<<endl;
int ans=0;
while (s[tmp]>='0'&&s[tmp]<='9'){
ans=ans*10+s[tmp]-'0';
tmp++;
}
//cout<<"getnmhhh "<<x<<endl;
return ans;
}
void build_a_tree(int pos){
//cout<<"build "<<pos<<" "<<tmp<<endl;
if (s[tmp]!='x'){
int x=get_a_num();
trees[pos].val=x;
++tmp;
return;
}
//
//if (pos>42000) cout<<"allright!\n";
int sl=tmp;
tmp+=2;int x=get_a_num();
trees[pos].islv=0;
trees[pos].val=x;
++tmp;
//left-subtree
trees[pos].l=++treecnt;
build_a_tree(treecnt);
//right-subtree
trees[pos].r=++treecnt;
build_a_tree(treecnt);
//
if (s[sl+1]=='>'){
trees[pos].flag=1;
}
return;
}
int x;
void sctree(){
int curnd=1;
while (!trees[curnd].islv){
if (!trees[curnd].flag){//<
if (x<trees[curnd].val){//1
curnd=trees[curnd].l;
}
else{//0
curnd=trees[curnd].r;
}
}
else{
if (x>trees[curnd].val){//1
curnd=trees[curnd].l;
}
else{//0
curnd=trees[curnd].r;
}
}
}
cout<<trees[curnd].val<<'\n';
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("expr2.in","r",stdin);
cin>>m>>q>>s;
build_a_tree(1);
/*
cout<<"\n";
for (int i=1;i<=7;i++){
cout<<trees[i].flag<<" "<<trees[i].islv<<"\n";
cout<<trees[i].l<<" "<<trees[i].r<<" "<<trees[i].val<<"\n";
cout<<"\n";
}
cout<<"\n";
*/
while (q--){
cin>>x;
sctree();
}
return 0;
}
网络上有说数组开太大的
但经过过检查自认为数组开的并不大。
求大佬帮忙看一下...谢谢!!
回复
共 6 条回复,欢迎继续交流。
正在加载回复...