QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65019#4592. Theramorezzxzzx123#WA 11ms3928kbC++1.4kb2022-11-26 14:30:392022-11-26 14:30:41

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-26 14:30:41]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3928kb
  • [2022-11-26 14:30:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
void sol(string& a,int flag,int& len,deque<int>& q){
	if(flag){
		while(!q.empty()&&!q.back()){
			a+=(char)('0'+q.back());
			q.pop_back();
			len--;
		}
	}else {
		while(!q.empty()&&!q.front()){
			a+=(char)('0'+q.front());
			q.pop_front();
			len--;
		}		
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		string ans="";
		int flag=0,len=0;//判断是偶数还是技术
		deque<int>q;
		for(int i=0;s[i];i++){
			if(len==0&&(s[i]=='0')){
				len=0;
				ans+="0";
				continue;
			}
			if((len&1)==0&&(s[i]=='0')){
				ans+="0";
				flag^=1;
				sol(s,flag,len,q);
				continue;
			}//那么就是变成了奇数反转
			if((len&1)==1&&(s[i]=='0')){
				if(!flag){
					q.push_back(0);
				}else {
					q.push_front(0);
				}
				len++;//没有进行翻转
				continue;
			}
			if(s[i]=='1'){
				if(!flag){
					q.push_back(1);
				}else {
					q.push_front(1);
				}
				len++;//没有进行翻转		
				continue;		
			}
		}
		while(!q.empty()){
			int cnt0=0,cnt1=0;
			while(!q.empty()){
				if(q.back()){
					cnt1++;
				}else {
					cnt0++;
				}
				q.pop_back();
			}
			for(int i=1;i<=cnt0;i++){
				ans+="10";
			}
			for(int i=1;i<=(cnt1-cnt0);i++){
				ans+="1";
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 11ms
memory: 3928kb

input:

10
101001
01101100000000101010
11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...

output:

001011
00000000001010101111
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer 3rd lines differ - expected: '000000000000000000000000000000...1111111111111111111111111111111', found: '000000000000000000000000000000...1111111111111111111111111111111'