QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#65022 | #4592. Theramore | zzxzzx123# | WA | 10ms | 3832kb | C++ | 1.4kb | 2022-11-26 15:44:45 | 2022-11-26 15:44:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
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;
if(flag){
while(!q.empty()&&!q.back()){
ans+=(char)('0'+q.back());
q.pop_back();
len--;
}
}else {
while(!q.empty()&&!q.front()){
ans+=(char)('0'+q.front());
q.pop_front();
len--;
}
}
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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 10ms
memory: 3832kb
input:
10 101001 01101100000000101010 11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...
output:
001011 00000000001010101111 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 3rd lines differ - expected: '000000000000000000000000000000...1111111111111111111111111111111', found: '000000000000000000000000000000...1111111111111111111111111111111'