QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#65017 | #4592. Theramore | zzxzzx123# | WA | 17ms | 4100kb | C++ | 1.5kb | 2022-11-26 14:18:02 | 2022-11-26 14:18:03 |
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;
for(int i=0;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;//没有进行翻转
}
}
while(!q.empty()){
int cnt0=0,cnt1=0;
if(flag){
while(!q.empty()){
if(q.back()){
cnt1++;
}else {
cnt0++;
}
q.pop_back();
}
}else {
while(!q.empty()){
if(q.front()){
cnt1++;
}
else cnt0++;
q.pop_front();
}
}
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: 17ms
memory: 4100kb
input:
10 101001 01101100000000101010 11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...
output:
001011 00000000001010101111 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 3rd lines differ - expected: '000000000000000000000000000000...1111111111111111111111111111111', found: '000000000000000000000000000000...1111111111111111111111111111111'