QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#294676#7857. (-1,1)-SumpletebrakzeroCompile Error//C++141.7kb2023-12-30 15:44:222023-12-30 15:44:22

Judging History

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

  • [2023-12-30 15:44:22]
  • 评测
  • [2023-12-30 15:44:22]
  • 提交

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];
}
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;}
		vec2.clear(); 
		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;
	}
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:58:31: error: ‘pq’ was not declared in this scope
   58 |         for(int i=1;i<=n;++i) pq.push(P(h[i],i));
      |                               ^~
answer.code:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:45:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |         for(int i=1;i<=n;++i) scanf("%d",&z[i]),pos[i]=i;
      |                               ~~~~~^~~~~~~~~~~~
answer.code:46:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |         for(int i=1;i<=n;++i) scanf("%d",&h[i]),pos2[i]=i;
      |                               ~~~~~^~~~~~~~~~~~