QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#65018#4592. Theramorezzxzzx123#WA 3ms3972kbC++1.4kb2022-11-26 14:27:322022-11-26 14:27:35

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:27:35]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3972kb
  • [2022-11-26 14:27:32]
  • 提交

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^=1;
		}
	}else {
		while(!q.empty()&&!q.front()){
			a+=(char)('0'+q.front());
			q.pop_front();
			len^=1;
		}		
	}
}
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;
		int i=0;
		while(s[i]&&(s[i]=='0')){
			ans+="0";
			i++;
		}
		for(;s[i];i++){
			if(len==0&&(s[i]=='0')){
				ans+="0";
				flag^=1;
				sol(s,flag,len,q);
				continue;
			}//那么就是变成了奇数反转
			if(len==1&&(s[i]=='0')){
				if(!flag){
					q.push_back(0);
				}else {
					q.push_front(0);
				}
				len^=1;//没有进行翻转
				continue;
			}
			if(s[i]=='1'){
				if(!flag){
					q.push_back(1);
				}else {
					q.push_front(1);
				}
				len^=1;//没有进行翻转		
				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;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3972kb

input:

10
101001
01101100000000101010
11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...

output:

001011
00000000001010101111
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

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