社区讨论
关于看不懂为什么CE
P7912[CSP-J 2021] 小熊的果篮参与者 4已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @lo7trvj9
- 此快照首次捕获于
- 2023/10/27 07:38 2 年前
- 此快照最后确认于
- 2023/10/27 07:38 2 年前
rt
CPP#include<bits/stdc++.h>
using namespace std;
struct var
{
int start,stop;
bool idx;
tt(int start,int stop,bool idx)
{
this->start=start;
this->stop=stop;
this->idx=idx
}
};queue<var>q;
const int sz=2e5+5;
bool usd[sz];
bool QreadB()
{
while(true)
{char c=getchar();if(c=='0' or c=='1')return c-'0';}
}
int main()
{
var tt;tt=var(1,1,QreadB())
for(int i=2;i<=n;++i)
{
bool obj=QreadB();
if(obj==tt.idx)++tt.stop;
else
{
q.push(tt);tt=var(i,i,obj);
}
}
q.push(tt);while(true)
{
//delete
queue<var>qq;
while(q.size())
{
var it=q.front();q.pop();
while(usd[it.start])++it.start;
cout<<idx<<' ';++it.start;
qq.push(it);usd[it.start-1]=true;
}
//clear empty
q=queue<var>();
while(qq.size())
{
var it=qq.front();qq.pop();
if(it.start>=it.stop)continue;
else q.push(it);
}
//check has
if(q.empty())break;cout<<endl;
//combination
vector<var>vc;vc.push(q.front());
q.pop();while(q.size())
{
var id=q.front();q.pop();
if(id.idx==vc.back().idx)
{
var it=vc.back();vc.pop_back();
id.stop=it.stop;
}
vc.push_back(id);
}
}
}
报错:
CPP/tmp/compiler_jch1z68m/src:7:35: 错误:ISO C++ 不允许声明无类型的‘tt’ [-fpermissive]
7 | tt(int start,int stop,bool idx)
| ^
/tmp/compiler_jch1z68m/src: 在成员函数‘int var::tt(int, int, bool)’中:
/tmp/compiler_jch1z68m/src:11:22: 错误:expected ‘;’ before ‘}’ token
11 | this->idx=idx
| ^
| ;
12 | }
| ~
/tmp/compiler_jch1z68m/src:12:5: 警告:在有返回值的函数中未发现 return 语句 [-Wreturn-type]
12 | }
| ^
/tmp/compiler_jch1z68m/src: 在函数‘int main()’中:
/tmp/compiler_jch1z68m/src:23:31: 错误:no matching function for call to ‘var::var(int, int, bool)’
23 | var tt;tt=var(1,1,QreadB())
| ^
/tmp/compiler_jch1z68m/src:3:8: 附注:candidate: ‘var::var()’
3 | struct var
| ^~~
/tmp/compiler_jch1z68m/src:3:8: 附注: 备选需要 0 实参,但提供了 3 个
/tmp/compiler_jch1z68m/src:3:8: 附注:candidate: ‘constexpr var::var(const var&)’
/tmp/compiler_jch1z68m/src:3:8: 附注: 备选需要 1 实参,但提供了 3 个
/tmp/compiler_jch1z68m/src:3:8: 附注:candidate: ‘constexpr var::var(var&&)’
/tmp/compiler_jch1z68m/src:3:8: 附注: 备选需要 1 实参,但提供了 3 个
/tmp/compiler_jch1z68m/src:24:17: 错误:‘i’在此作用域中尚未声明
24 | for(int i=2;i<=n;++i)
| ^
/tmp/compiler_jch1z68m/src:24:20: 错误:‘n’在此作用域中尚未声明
24 | for(int i=2;i<=n;++i)
| ^
/tmp/compiler_jch1z68m/src:41:19: 错误:‘idx’在此作用域中尚未声明
41 | cout<<idx<<' ';++it.start;
| ^~~
/tmp/compiler_jch1z68m/src:53:9: 警告:this ‘if’ clause does not guard... [-Wmisleading-indentation]
53 | if(q.empty())break;cout<<endl;
| ^~
/tmp/compiler_jch1z68m/src:53:28: 附注:...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
53 | if(q.empty())break;cout<<endl;
| ^~~~
/tmp/compiler_jch1z68m/src:55:26: 错误:‘class std::vector<var>’ has no member named ‘push’
55 | vector<var>vc;vc.push(q.front());
| ^~~~
回复
共 7 条回复,欢迎继续交流。
正在加载回复...