QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786411#4671. Independent Rectanglesucup-team266#Compile Error//C++234.6kb2024-11-26 21:24:562024-11-26 21:24:58

Judging History

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

  • [2024-11-26 21:24:58]
  • 评测
  • [2024-11-26 21:24:56]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
#define ls (x<<1)
#define rs (ls|1)
int n;
int x1[100100],x2[100100],y1[100100],y2[100100];
namespace segt1
{
	ll segt[1001000<<2],tag[1001000<<2];
	void update(int x,int l,int r,int ql,int qr,ll v)
	{
		if(ql<=l&&r<=qr)
		{
			tag[x]+=v;
			segt[x]+=v*(r-l+1);
			return ;
		}
		int mid=(l+r)/2;
		if(ql<=mid) update(ls,l,mid,ql,qr,v);
		if(qr>mid) update(rs,mid+1,r,ql,qr,v);
		segt[x]=segt[ls]+segt[rs]+tag[x]*(r-l+1);
	}
	ll query(int x,int l,int r,int ql,int qr)
	{
		if(ql<=l&&r<=qr) return segt[x];
		ll res=(min(r,qr)-max(l,ql)+1)*tag[x];
		int mid=(l+r)/2;
		if(ql<=mid) res+=query(ls,l,mid,ql,qr);
		if(qr>mid) res+=query(rs,mid+1,r,ql,qr);
		return res;
	}
	void clear()
	{
		memset(segt,0,sizeof(segt));
		memset(tag,0,sizeof(tag));
	}
}
namespace segt2
{
	ll segt[1001000<<2],tag[1001000<<2];
	void update(int x,int l,int r,int ql,int qr,ll v)
	{
		if(ql<=l&&r<=qr)
		{
			tag[x]+=v;
			segt[x]+=v*(r-l+1);
			return ;
		}
		int mid=(l+r)/2;
		if(ql<=mid) update(ls,l,mid,ql,qr,v);
		if(qr>mid) update(rs,mid+1,r,ql,qr,v);
		segt[x]=segt[ls]+segt[rs]+tag[x]*(r-l+1);
	}
	ll query(int x,int l,int r,int ql,int qr)
	{
		if(ql<=l&&r<=qr) return segt[x];
		ll res=(min(r,qr)-max(l,ql)+1)*tag[x];
		int mid=(l+r)/2;
		if(ql<=mid) res+=query(ls,l,mid,ql,qr);
		if(qr>mid) res+=query(rs,mid+1,r,ql,qr);
		return res;
	}
	void clear()
	{
		memset(segt,0,sizeof(segt));
		memset(tag,0,sizeof(tag));
	}
}
namespace segt3
{
	ll segt[1001000<<2],tag[1001000<<2];
	void update(int x,int l,int r,int ql,int qr,ll v)
	{
		if(ql<=l&&r<=qr)
		{
			tag[x]+=v;
			segt[x]+=v*(r-l+1);
			return ;
		}
		int mid=(l+r)/2;
		if(ql<=mid) update(ls,l,mid,ql,qr,v);
		if(qr>mid) update(rs,mid+1,r,ql,qr,v);
		segt[x]=segt[ls]+segt[rs]+tag[x]*(r-l+1);
	}
	ll query(int x,int l,int r,int ql,int qr)
	{
		if(ql<=l&&r<=qr) return segt[x];
		ll res=(min(r,qr)-max(l,ql)+1)*tag[x];
		int mid=(l+r)/2;
		if(ql<=mid) res+=query(ls,l,mid,ql,qr);
		if(qr>mid) res+=query(rs,mid+1,r,ql,qr);
		return res;
	}
	void clear()
	{
		memset(segt,0,sizeof(segt));
		memset(tag,0,sizeof(tag));
	}
}
const int thres=1e6;
int alive[100100];
int cnt[100100],to[100100];
vector<int> vadd[1001000],vdel[1001000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
	vector<int> vind;
	for(int i=1;i<=n;i++)
		vind.pb(i);
	for(int i=1;i<=n;i++)
		vadd[x1[i]].pb(i);
	for(int i=1;i<=n;i++)
		vdel[x2[i]].pb(i);
	for(int i=0;i<=thres;i++)
	{
		for(auto ind:vdel[i])
		{
			segt1::update(1,0,thres,y1[ind],y2[ind]-1,-1);
			segt3::update(1,0,thres,y1[ind],y2[ind]-1,-ind);
			if(y1[ind]<y2[ind]-1)
				segt2::update(1,0,thres,y1[ind],y2[ind]-2,-1);
			alive[ind]=0;
		}
		for(auto ind:vadd[i])
		{
			cnt[ind]+=segt1::query(1,0,thres,y1[ind],y2[ind]-1);
			if(y1[ind]<y2[ind]-1)
				cnt[ind]-=segt2::query(1,0,thres,y1[ind],y2[ind]-2);
			if(cnt[ind]==1)
				to[ind]=segt3::query(1,0,thres,y1[ind],y2[ind]-1)/segt1::query(1,0,thres,y1[ind],y2[ind]-1);
			segt1::update(1,0,thres,y1[ind],y2[ind]-1,1);
			segt3::update(1,0,thres,y1[ind],y2[ind]-1,ind);
			if(y1[ind]<y2[ind]-1)
				segt2::update(1,0,thres,y1[ind],y2[ind]-2,1);
			alive[ind]=1;
		}
	}
	segt1::clear();
	segt2::clear();
	segt3::clear();
	for(int i=thres;i>=0;i--)
	{
		rev(vadd[i]);
		for(auto ind:vadd[i])
		{
			cnt[ind]+=segt1::query(1,0,thres,y1[ind],y2[ind]-1);
			if(y1[ind]<y2[ind]-1)
				cnt[ind]-=segt2::query(1,0,thres,y1[ind],y2[ind]-2);
			segt1::update(1,0,thres,y1[ind],y2[ind]-1,1);
			if(y1[ind]<y2[ind]-1)
				segt2::update(1,0,thres,y1[ind],y2[ind]-2,1);
		}
		for(auto ind:vdel[i])
		{
			cnt[ind]-=segt1::query(1,0,thres,y1[ind],y2[ind]-1);
			if(y1[ind]<y2[ind]-1)
				cnt[ind]+=segt2::query(1,0,thres,y1[ind],y2[ind]-2);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(cnt[i]==1&&to[i]&&cnt[to[i]]==1)
			ans++;
	cout<<ans<<'\n';
	return 0;
}

Details

answer.code:25:36: error: ‘int y1 [100100]’ redeclared as different kind of entity
   25 | int x1[100100],x2[100100],y1[100100],y2[100100];
      |                                    ^
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/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:33,
                 from answer.code:2:
/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 ‘int main()’:
answer.code:130:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  130 |                 cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
      |                                 ^
answer.code:130:27: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘double(double) noexcept’)
  130 |                 cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
      |                 ~~~~~~~~~~^~~~~~~
      |                    |            |
      |                    |            double(double) noexcept
      |                    std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:130:33: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘void*’ [-fpermissive]
  130 |                 cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
      |                             ~~~~^
      |                                 |
      |                                 double (*)(double) noexcept
answer.code:130:33: error: cannot bind rvalue ‘(void*)(y1 + ((sizetype)i))’ to ‘void*&’
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:130:33: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘long long unsigned int’ [-fpermissive]
  130 |                 cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
      |                             ~~~~^
      |                                 |
      |                                 double (*)(double) noexcept
answer.code:130:33: error: cannot bind rvalue ‘(long long unsigned int)(y1 + ((sizetype)i))’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:130:33: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘long long int’ [-fpermissive]
  130 |                 cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
      |                             ~~~~^
      |                                 |
      |                                 double (*)(double) noexcept
answer.code:130:33: error: cannot bind rvalue ‘(long long int)(y1 + ((sizetype)i))’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:130:33: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘long unsigned int’ [-fpermissive]
  130 |                 cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
      |                             ~~~~^
      |                                 |
      |                 ...