QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409861#6746. Merge the Rectangleslzx2017Compile Error//C++201.8kb2024-05-12 19:46:072024-05-12 19:46:07

Judging History

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

  • [2024-05-12 19:46:07]
  • 评测
  • [2024-05-12 19:46:07]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
int fa[N*N],siz[N*N];
int x1[N*N],x2[N*N],y1[N*N],y2[N*N];
int n,m;
int id(int x,int y){
	return (x*N+y);
}
int find(int x){
	if(fa[x]==x)return x;
	else fa[x]=find(fa[x]);
	return fa[x];
}
int tot;
void merge(int a,int b){
	
	if(fa[a]==fa[b])return;
	find(a);find(b);
	int x=fa[a],y=fa[b];
	if(siz[x]<siz[y])swap(x,y);
	fa[y]=x;
	siz[x]+=siz[y];
	x1[x]=min(x1[x],x1[y]);
	x2[x]=max(x2[x],x2[y]);
	y1[x]=min(y1[x],y1[y]);
	y2[x]=max(y2[x],y2[y]);
	tot--;
}
queue<pair<int,int>>q;
void check(int u){
	int v;
	if(y2[u]+1<=n){
		v=id(x1[u],y2[u]+1);
		if(x1[v]==x1[u]&&x2[v]==x2[v])q.push({u,v});
	}
	if(y1[u]-1>=1){
		v=id(x1[u],y1[u]-1);
		if(x1[v]==x1[u]&&x2[v]==x2[v])q.push({u,v});
	}
	if(x1[u]-1>=1){
		v=id(x1[u]-1,y1[u]);
		if(y1[v]==y1[u]&&y2[v]==y2[v])q.push({u,v});
	}
	if(x2[u]+1<=n){
		v=id(x2[u]+1,y1[u]);
		if(y1[v]==y1[u]&&y2[v]==y2[v])q.push({u,v});
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>n>>m;
	tot=n;
	for(int i=0;i<N*N;i++)fa[i]=i;
	for(int i=1;i<n;i++){
		string s;
		cin>>s;
		s=" "+s;
		for(int j=1;j<=m;j++){
			if(s[j]=='1')continue;
			merge(id(i,j),id(i+1,j));
		}
	}
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		s=" "+s;
		for(int j=1;j<m;j++){
			if(s[j]=='1')continue;
			merge(id(i,j),id(i,j+1));
		}
	}

	for(int i=1;i=n;i++){
		for(int j=1;j<=m;j++){
			int u=id(i,j);
			if(fa[u]!=u)continue;
			check(u);
		}
	}
	while(q.size()){
		int u=q.front().first;
		int v=q.front().second;
		if(x1[v]==x1[u]&&x2[v]==x2[v])
			merge(u,v);
		if(y1[v]==y1[u]&&y2[v]==y2[v])
			merge(u,v);
		int f=fa[u];
		check(f);
	}
	if(tot==1){
		cout<<"YES\n";
	}
	else cout<<"NO\n";
}

Details

answer.code:10:27: error: ‘int y1 [2265025]’ redeclared as different kind of entity
   10 | int x1[N*N],x2[N*N],y1[N*N],y2[N*N];
      |                           ^
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679,
                 from /usr/include/c++/13/cstdio:41,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration ‘double y1(double)’
  221 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
answer.code: In function ‘void merge(int, int)’:
answer.code:31:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |         y1[x]=min(y1[x],y1[y]);
      |             ^
answer.code:31:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |         y1[x]=min(y1[x],y1[y]);
      |                       ^
answer.code:31:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |         y1[x]=min(y1[x],y1[y]);
      |                             ^
answer.code:31:14: error: assignment of read-only location ‘*(y1 + ((sizetype)x))’
   31 |         y1[x]=min(y1[x],y1[y]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
answer.code: In function ‘void check(int)’:
answer.code:42:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |         if(y1[u]-1>=1){
      |                ^
answer.code:42:17: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |         if(y1[u]-1>=1){
      |            ~~~~~^~
answer.code:42:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   42 |         if(y1[u]-1>=1){
      |            ~~~~~~~^~~
answer.code:43:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   43 |                 v=id(x1[u],y1[u]-1);
      |                                ^
answer.code:43:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   43 |                 v=id(x1[u],y1[u]-1);
      |                            ~~~~~^~
answer.code:43:33: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘int’ [-fpermissive]
   43 |                 v=id(x1[u],y1[u]-1);
      |                            ~~~~~^~
      |                                 |
      |                                 double (*)(double) noexcept
answer.code:12:18: note:   initializing argument 2 of ‘int id(int, int)’
   12 | int id(int x,int y){
      |              ~~~~^
answer.code:47:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   47 |                 v=id(x1[u]-1,y1[u]);
      |                                  ^
answer.code:47:34: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘int’ [-fpermissive]
   47 |                 v=id(x1[u]-1,y1[u]);
      |                              ~~~~^
      |                                  |
      |                                  double (*)(double) noexcept
answer.code:12:18: note:   initializing argument 2 of ‘int id(int, int)’
   12 | int id(int x,int y){
      |              ~~~~^
answer.code:48:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   48 |                 if(y1[v]==y1[u]&&y2[v]==y2[v])q.push({u,v});
      |                        ^
answer.code:48:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   48 |                 if(y1[v]==y1[u]&&y2[v]==y2[v])q.push({u,v});
      |                               ^
answer.code:51:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |                 v=id(x2[u]+1,y1[u]);
      |                                  ^
answer.code:51:34: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘int’ [-fpermissive]
   51 |                 v=id(x2[u]+1,y1[u]);
      |                              ~~~~^
      |                                  |
      |                                  double (*)(double) noexcept
answer.code:12:18: note:   initializing argument 2 of ‘int id(int, int)’
   12 | int id(int x,int y){
      |              ~~~~^
answer.code:52:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                 if(y1[v]==y1[u]&&y2[v]==y2[v])q.push({u,v});
      |                        ^
answer.code:52:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                 if(y1[v]==y1[u]&&y2[v]==y2[v])q.push({u,v});
      |                               ^
answer.code: In function ‘int main()’:
answer.code:93:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   93 |                 if(y1[v]==y1[u]&&y2[v]==y2[v])
      |                        ^
answer.code:93:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   93 |                 if(y1[v]==y1[u]&&y2[v]==y2[v])
      |                               ^