QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294636#7857. (-1,1)-SumpletebrakzeroWA 0ms3844kbC++141.3kb2023-12-30 15:12:462023-12-30 15:12:47

Judging History

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

  • [2023-12-30 15:12:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2023-12-30 15:12:46]
  • 提交

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;
vector<int> vec1,vec2;
bool comp(int x,int y)
{
	return z[x]<z[y];
}
priority_queue<pair<int,int> >pq;  
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]);
	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);
	int nows=-1;
	for(int i=1;i<=n;++i)
	{
		while(z[pos[i]]--)
		{
			if(nows<0)
			{
				swap(vec1,vec2);
				vec2.clear();
				while(vec1.size()==0||(pq.size()&&pq.top().first==h[vec1[0]]))
				{
					vec1.push_back(pq.top().second);
					pq.pop();
				}
				nows=vec1.size()-1;
			}
			int x=vec1[nows--];
			h[x]--;
			res[pos[i]][x]^=1;
			vec2.push_back(x);
		}
	}
	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: 3844kb

input:

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

output:

Yes
111
111
111

result:

ok n=3

Test #2:

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

input:

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

output:

Yes
110
100
000

result:

ok n=3

Test #3:

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

input:

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

output:

Yes
010
000
011

result:

wrong answer wrong sum at row 1