QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294673#7857. (-1,1)-SumpletebrakzeroWA 1ms5824kbC++141.7kb2023-12-30 15:41:542023-12-30 15:41:54

Judging History

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

  • [2023-12-30 15:41:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5824kb
  • [2023-12-30 15:41:54]
  • 提交

answer

#include<bits/stdc++.h>
#define P make_pair 
using namespace std;
bool res[4001][4001];
int z[4001],h[4001];
int pos[4001],n,pos2[4001];
vector<int> vec1,vec2,vec3;
bool comp(int x,int y)
{
	return z[x]<z[y];
}
bool comp2(int x,int y)
{
	return h[x]>h[y];
}
priority_queue<pair<int,int> >pq;
void gb()
{
	vec3.clear();
	int l=0,r=0;
	while(l<vec1.size()&&r<vec2.size())
	{
		if(h[vec1[l]]>h[vec2[r]])
		{
			vec3.push_back(vec1[l++]);
		}
		else vec3.push_back(vec2[r++]);
	 } 
	while(l<vec1.size()) vec3.push_back(vec1[l++]);
	while(r<vec2.size()) vec3.push_back(vec2[r++]);
	swap(vec3,vec1);
}
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			char c;
			cin>>c;
			if(c=='+') res[i][j]=false;
			else res[i][j]=true;
		}
	}
	for(int i=1;i<=n;++i) scanf("%d",&z[i]),pos[i]=i;
	for(int i=1;i<=n;++i) scanf("%d",&h[i]),pos2[i]=i;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(res[i][j]==true)
			{
				z[i]++;
				h[j]++;
			}
		}
	}
	for(int i=1;i<=n;++i) pq.push(P(h[i],i));
	sort(pos+1,pos+1+n,comp);
	sort(pos2+1,pos2+1+n,comp2);
	for(int i=1;i<=n;++i) vec1.push_back(pos2[i]);
	for(int i=1;i<=n;++i)
	{
		if(z[pos[i]]>n||z[pos[i]]<0) {cout<<"No";return 0;}
		for(int j=0;j<z[pos[i]];++j)
		{
			h[vec1[j]]--;
			res[pos[i]][vec1[j]]^=1;
			vec2.push_back(vec1[j]);
		}
		vec3.clear();
		for(int j=z[pos[i]];j<n;++j) vec3.push_back(vec1[j]);
		swap(vec3,vec1);
		gb();
	}
	for(int i=1;i<=n;++i)
	{
		if(h[i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(res[i][j]) cout<<"1";
			else cout<<"0";
		}
		cout<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3796kb

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

Yes
111
001
001

result:

ok n=3

Test #2:

score: 0
Accepted
time: 1ms
memory: 5824kb

input:

3
---
-++
+++
-2 -1 0
-2 -1 0

output:

Yes
110
100
000

result:

ok n=3

Test #3:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

3
+-+
-++
++-
1 0 2
2 2 -1

output:

No

result:

ok n=3

Test #4:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3772kb

input:

20
+-------+-----+++-++
-+-++++----++-++-++-
-+++--+---+--+-++---
-+++-+--+----++---+-
+++-+-++++++-+-+---+
-++-----+----++++++-
+-++--+++++-++-+----
+-+----+---+-+++--+-
+++++-+++++----+--+-
------++++---+--++--
++++--------++++--+-
-+-+-++++-+-++-++--+
---+-++---+-++-++---
+-++++-++----+-+++--
+-+...

output:

No

result:

wrong answer Jury has the answer but participant has not