QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#832805 | #1289. A + B Problem | CHD | WA | 26ms | 4872kb | C++14 | 2.1kb | 2024-12-26 08:33:28 | 2024-12-26 08:33:29 |
Judging History
answer
#include<cstdio>
using namespace std;
int T,I,n,m,w[2100000],i,j;
void read(int &x,int w=20)
{
int cnt=1;
char s=getchar();
while(s<'0'||s>'9')
s=getchar();
x=s-'0';
while(cnt<w)
{
s=getchar();
if(s<'0'||s>'9')
return;
cnt++;
x=x*10+s-'0';
}
}
void put(unsigned int w,int d=1)
{
if(w==0&&d<=0)
return;
put(w>>1,d-1);
putchar((w&1)+'0');
}
class bin
{
public:
int w;
unsigned int *s;
bin():w(0),s(NULL){}
bin(const bin &x):w(x.w)
{
int i;
s=new unsigned int[w];
for(i=0;i<w;i++)
s[i]=x.s[i];
}
void reset(int l)
{
int i;
this->w=l;
if(this->s!=NULL)
delete [] this->s;
this->s=new unsigned int[this->w];
for(i=0;i<this->w;i++)
this->s[i]=0;
}
void set(int w)
{
this->s[w>>5]^=1u<<(w&31);
}
bin & operator = (const bin &x)
{
int i;
if(this->s!=NULL)
delete [] this->s;
this->w=x.w;
this->s=new unsigned int[this->w];
for(i=0;i<this->w;i++)
this->s[i]=x.s[i];
return *this;
}
bin operator + (const bin &x) const
{
bin ans;
int i=this->w;
unsigned int z,a,b,c;
if(x.w>i)
i=x.w;
ans.reset(i+1);
for(i=0;i<ans.w;i++)
{
a=ans.s[i];
if(i<this->w)
b=this->s[i];
else
b=0;
if(i<x.w)
c=x.s[i];
else
c=0;
z=a;
if(b>z)
z=b;
if(c>z)
z=c;
ans.s[i]=a+b+c;
if(ans.s[i]<z)
ans.s[i+1]=1;
}
return ans;
}
void print() const
{
int i;
for(i=this->w-1;i>0;i--)
if(this->s[i]!=0)
break;
put(this->s[i]);
for(i--;i>=0;i--)
put(this->s[i],32);
putchar('\n');
}
}a,b;
main()
{
read(T);
for(I=1;I<=T;I++)
{
read(n);
read(m);
for(i=1;i<=n+m;i++)
read(w[i],1);
if(n<m)
{
i=n;
n=m;
m=i;
}
a.reset((n>>5)+1);
b.reset((m>>5)+1);
for(i=1;i<=m;i++)
if(w[i]==1)
b.set(m-i);
for(i=1;i<=n;i++)
if(w[i+m]==1)
a.set(n-i);
j=m;
while(j>0&&w[j]==0)
j--;
for(i=1;i<=n&&j>0;i++)
if(w[i+m]==0)
{
if(m-j>=n-i)
break;
a.set(n-i);
b.set(m-j);
j--;
while(j>0&&w[j]==0)
j--;
}
(a+b).print();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
input:
3 4 3 1000101 2 2 1111 1 1 00
output:
1101 110 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 4872kb
input:
11110 10 8 111011010011100100 3 5 01011000 7 6 1110101010000 9 1 0110100101 1 9 0100001110 8 10 000101101011111000 9 6 011111111000111 1 9 1011101101 10 7 00100011000100000 4 9 1000101101010 8 4 100100110000 8 9 00101111011000101 8 9 11000000101011110 7 6 1111010100110 2 9 01001110101 4 5 100010100 ...
output:
10011010100 11100 10101000 110100101 100001110 10000001100 1000010111 111101101 1110100000 111101010 11110000 1000011101 1001011110 10101110 101110101 11100 1111010 1000010 1011100010 10010101001 10010001 1001010 1000000010 1110 111 1111110001 10110111 1100010101 10000000 111000011 110 11111 1100101...
result:
wrong answer 10991st lines differ - expected: '100000000111111111111111111111...1111111111111111111111111111110', found: '100000000111111111111111111111...1111111111111111111111111111110'