第四个点错了 到底哪里写挂了?
查看原帖
第四个点错了 到底哪里写挂了?
432183
JoeBiden2020楼主2021/10/29 21:09

rt,红题让我心态爆炸

#include<bits/stdc++.h>
using namespace std;
string s[50001],temp,ans[50001];
bool vis[50001],flag;
int n=0,tot=0,len;
void work(int pos){
	for(int i=pos;i>=1;i--){
		if(vis[i])break; 
		if(s[i]=="not"&&s[i-1]=="not"){
			vis[i]=vis[i-1]=true;
		}
	}
}
int main(){
	while(cin>>temp){
		s[++n]=temp;
	}
    if(s[n]=="not")len=n-2;
    else len=n-1;
	for(int i=1;i<=len;i++){
		work(i);
	}
    for(int i=1;i<=n;i++){
        if(!vis[i])ans[++tot]=s[i];
    }
    if(tot==1){
        cout<<ans[1]<<endl;
        return 0;
    }
	for(int i=1;i<=tot-1;i++){
		cout<<ans[i]<<" ";
	}
    cout<<ans[tot]<<endl;
	return 0;
} 
2021/10/29 21:09
加载中...