QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#125895#4256. 最大异或和zhouhuanyi100 ✓359ms10828kbC++142.1kb2023-07-17 21:24:062023-07-17 21:24:08

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-17 21:24:08]
  • 评测
  • 测评结果:100
  • 用时:359ms
  • 内存:10828kb
  • [2023-07-17 21:24:06]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#define N 2000
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
struct reads
{
	int l,r;
	bitset<N+1>d;
	bool operator < (const reads &t)const
	{
		return l<t.l;
	}
};
reads st[10*N+1];
bitset<N+1>B[N+1];
bitset<N+1>a[N+1];
bitset<N+1>b[N+1];
bitset<N+1>c[N+1];
bitset<N+1>tmp;
bitset<N+1>zero;
bitset<N+1>delta[N+1];
int n,m,q,op[N+1],ps[N+1],sr[N+1],length;
bitset<N+1>get()
{
	char c;
	for (int i=1;i<=m;++i) cin>>c,tmp[i]=c-'0';
	return tmp;
}
void output(bitset<N+1>d)
{
	for (int i=1;i<=m;++i) printf("%d",(int)(d[i]));
	puts("");
	return;
}
void change(int x,int t,bitset<N+1>d)
{
	st[++length]=(reads){ps[x],t-1,a[x]},a[x]=d,ps[x]=t;
	return;
}
void Insert(bitset<N+1>d,int t)
{
	for (int i=1;i<=m;++i)
		if (d[i])
		{
			if (!c[i][i])
			{
				c[i]=d,sr[i]=t;
				return;
			}
			else
			{
				if (sr[i]<t) swap(c[i],d),swap(sr[i],t);
				d^=c[i];
			}
		}
	return;
}
bitset<N+1>query(int t)
{
	bitset<N+1>res;
	for (int i=1;i<=m;++i)
		if (!res[i]&&sr[i]>=t&&c[i][i])
			res^=c[i];
	return res;
}
int main()
{
	int l,r,pst=0;
	bitset<N+1>d;
	n=read(),m=read(),q=read();
	for (int i=1;i<=n;++i) a[i]=get();
	for (int i=n;i>=1;--i) a[i]^=a[i-1];
	for (int i=1;i<=n;++i) ps[i]=0;
	for (int i=1;i<=q;++i)
	{
		op[i]=read();
		if (op[i]==1)
		{
			l=read(),r=read(),d=get(),change(l,i,a[l]^d);
			if (r+1<=n) change(r+1,i,a[r+1]^d);
		}
		else if (op[i]==2)
		{
			for (int j=1;j<=n;++j) b[j]=b[j-1]^a[j];
			l=read(),r=read(),d=get(),change(l,i,d^b[l-1]);
			for (int j=l+1;j<=r;++j)
				if (a[j].any())
					change(j,i,zero);
			if (r+1<=n) change(r+1,i,b[r+1]^d);
		}
	}
	for (int i=1;i<=n;++i) st[++length]=(reads){ps[i],q,a[i]};
	sort(st+1,st+length+1);
	for (int i=1;i<=q;++i)
	{
		while (pst+1<=length&&st[pst+1].l<=i) ++pst,Insert(st[pst].d,st[pst].r);
		if (op[i]==3) output(query(i));
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 10
Accepted
time: 3ms
memory: 10764kb

input:

10 10 1000
0000001100
0110100010
0000110101
0100011011
0111111000
0111100110
0111100001
1000111111
0001100011
1110111101
1 3 6 1011011010
3
2 4 8 1110001101
3
2 4 5 0110010111
3
2 5 5 0111111110
3
2 4 7 0101000101
3
2 2 2 1011001111
3
2 1 1 0100101010
3
2 6 7 0001000101
3
2 1 9 0000100100
3
2 7 10 0...

output:

1111111111
1111101110
1111101110
1111101110
1111111001
1111111110
1111111110
1111111111
1110111101
0011110101
1111110010
1111110010
1111110010
1111111010
1111111010
1111111010
1111111010
1111111110
1111111010
1111111010
1111111010
1111111110
1110011110
1111101110
1111111110
1111111101
1111011001
111...

result:

ok 500 tokens

Test #2:

score: 10
Accepted
time: 13ms
memory: 9992kb

input:

500 500 10
1100000100011111011100000111000001010110011001100101010011111101100110111001110111011110000001011100001000011101011110010111001100111011010100110110110011101101001100110110000011000111110011100111100011000010100000000000111011101010111001001001111000111110111011110110001010110010010111010...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 5 tokens

Test #3:

score: 10
Accepted
time: 4ms
memory: 10052kb

input:

120 120 120
000000100110110101001001111111000101001111000111010101001100100000111000110110110100110010101000101011000110100011001110
001100001110110100010111101110111010010010011001010011001110011001100011111011011111010111111101011011010011110110011001
0001010011110011101011110010101100001001011001...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110110011110
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111001101000
1111111111111111111111111111111111111111111111111111111111...

result:

ok 60 tokens

Test #4:

score: 10
Accepted
time: 165ms
memory: 10736kb

input:

2000 2000 10
01000011000011101010010110100010000011111000011010100110110111011010001111010000110011010001111100000011101100010111010001100110100110101110100111000011000011100011111011010111100010001101100110100100000011000100111111000100110000000001100111001001110111010011101111110101100010011001100...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 5 tokens

Test #5:

score: 10
Accepted
time: 294ms
memory: 10724kb

input:

1800 1800 1800
001101010111111011100100010111011100010011011000111111101101001010101110110001110001001010101101101001011111000110111010001110010000110110110100011110001010111111111100100100010010011010010110010001010011110010110010101010110001101100110101110101011000100100011010001101100010101011001...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 900 tokens

Test #6:

score: 10
Accepted
time: 273ms
memory: 10768kb

input:

1800 1800 1800
000101001100000110010101010100101110110011100011101100100000101100010011100010101101011001111110000100001111001101111011010110001101111000101101000110000010001001110011000000001011010010011010011111011000110111100101111010011000001100111001010010011001110010110000000001110001000100000...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 900 tokens

Test #7:

score: 10
Accepted
time: 297ms
memory: 10648kb

input:

1800 1800 1800
101110010111110011100100001001110110110001111110101001000001001001101001110111010000100100001001000001110100101010010101001000001101101011101001101111111000101000000011111110011001001011110101101110001010111111001110011010110000010010000101100000000000101100001011100000010100000110111...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 900 tokens

Test #8:

score: 10
Accepted
time: 200ms
memory: 10752kb

input:

1500 1500 1500
101000101000111101000010000100111110001110011101101001101101000001101111111111101010011100010011011000101010001110101111010100100111100001100101001100010100101001101001011011100001000111001000111111100010111011100010101101100101111100100110010110010001111100001110101011011011110010111...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 750 tokens

Test #9:

score: 10
Accepted
time: 281ms
memory: 10680kb

input:

1800 1800 1800
010010010101101101010000111001111010110101011000101000011101000111110111010100010101100011101101001001111111000010101111001100100000110001000101111000001101001100010000010110001110011100100001110101110101000101110011101100001110010000010011000010011101010100111110101101100001110101101...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 900 tokens

Test #10:

score: 10
Accepted
time: 359ms
memory: 10828kb

input:

2000 2000 2000
010101100001100000010011101110000011000010000011110011110010010100010100110111110111010101010110010010000011111011010101000111000011101100110111000101011111110100010110100001001110110001100111010100001101000110010010001111100010111010110001100010101111001111100100101111011011011110100...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 1000 tokens

Extra Test:

score: 0
Extra Test Passed