社区讨论
求助亿下下!!!60分!!!悬关!!!
P7912[CSP-J 2021] 小熊的果篮参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @m2bqx8em
- 此快照首次捕获于
- 2024/10/16 18:45 去年
- 此快照最后确认于
- 2024/10/16 20:56 去年
求助,两个代码修一个就行,谢谢大神们!!!
CPP#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ll;
struct node{
int num,ans;
};
queue<node> a,b;
signed main(){
cin>>n;
for(int i=1;i<=n;i++){
node t;
t.num=i;
cin>>t.ans;
a.push(t);
}
bool uu=0;
while(ll!=n){
if(uu==0){
int kk=-1;
int u=a.size();
for(int i=0;i<u;i++){
node t=a.front();
a.pop();
if(t.ans!=kk){
kk=t.ans;
cout<<t.num<<" ";
ll++;
}
else b.push(t);
}
cout<<endl;
uu=1;
}
else {
int kk=-1;
int u=b.size();
for(int i=0;i<u;i++){
node t=b.front();
b.pop();
if(t.ans!=kk){
kk=t.ans;
cout<<t.num<<" ";
ll++;
}
else a.push(t);
}
cout<<endl;
uu=0;
}
}
return 0;
}
CPP#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,longg;
struct node{
int num,ans;
bool o;
};
vector<node> a;
signed main(){
cin>>n;
for(int i=1;i<=n;i++){
node t;
cin>>t.ans;
t.num=i;
t.o=0;
a.push_back(t);
}
while(longg!=n){
int kk=-1;
for(int i=0;i<a.size();i++){
if(a[i].o==0){
if(a[i].ans!=kk){
kk=a[i].ans;
cout<<a[i].num<<' ';
a[i].o=1;
longg++;
}
}
}
cout<<"\n";
}
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...