QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65018 | #4592. Theramore | zzxzzx123# | WA | 3ms | 3972kb | C++ | 1.4kb | 2022-11-26 14:27:32 | 2022-11-26 14:27:35 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'