QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#732290#833. Cells BlockingTheZoneCompile Error//C++207.2kb2024-11-10 13:55:282024-11-10 13:55:29

Judging History

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

  • [2024-11-10 13:55:29]
  • 评测
  • [2024-11-10 13:55:28]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
const int N=3009;
char s[N][N];
int _1[N][N],_2[N][N];
int dd[N][N],dr[N][N],rr[N][N],rd[N][N];
int rrsum[2*N];
int drsum[2*N];
int rdsum[2*N];
int ddsum[2*N];
ll ans,num;
int cnt[2*N];
int n,m;
pii kkr[2*N],kkd[2*N];
void solve()
{
  	int x=1,y=1;
	kkr[2]=kkd[2]=mp(1,1);
	while(x!=n||y!=m)
	{
	  	if(x<n && s[x+1][y]=='.') ++x;
		else ++y;
		kkd[x+y]=mp(x,y);
	}
	x=y=1;
	while(x!=n||y!=m)
	{
	  	if(y<m && s[x][y+1]=='.') ++y;
		else ++x;
		kkr[x+y]=mp(x,y);
	}
}
void chkmax(int &a,int b)
{
  	if(b>a) a=b;
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m;
	F(i,1,n)cin>>s[i]+1;
	_1[1][1]=s[1][1]=='.';F(i,1,n)F(j,1,m) if(s[i][j]=='.') _1[i][j]|=_1[i][j-1]|_1[i-1][j];
	_2[n][m]=s[n][m]=='.';G(i,n,1)G(j,m,1) if(s[i][j]=='.') _2[i][j]|=_2[i][j+1]|_2[i+1][j];
	F(i,1,n)F(j,1,m)if(s[i][j]=='.'&&!(_1[i][j]&&_2[i][j]))s[i][j]='^';
	F(i,1,n)F(j,1,m)cnt[i+j]+=s[i][j]=='.',num+=s[i][j]!='*';
	if(s[1][1]!='.')
	{
	  	cout<<num*(num-1)/2<<'\n';
		return 0;
	}
	F(i,2,n+m) if(cnt[i]==1) ans+=--num;
	solve();
	G(i,n,1)G(j,m,1)
	{
	  	if(s[i][j]!='.') continue;
		if(kkd[i+j+1]==mp(i,j+1)) dd[i][j]=i+j+1;
		else if(kkr[i+j+1]!=mp(i,j+1))chkmax(dd[i][j],dd[i][j+1]);
		if(kkd[i+1+j]==mp(i+1,j)) chkmax(dd[i][j],i+j+1);
		else if(kkr[i+j+1]!=mp(i+1,j))chkmax(dd[i][j],dd[i+1][j]);
	}
	G(i,n,1)G(j,m,1)
	{
	  	if(s[i][j]!='.') continue;
		if(kkr[i+j+1]==mp(i,j+1)) rr[i][j]=i+j+1;
		else if(kkd[i+j+1]!=mp(i,j+1))chkmax(rr[i][j],rr[i][j+1]);
		if(kkr[i+1+j]==mp(i+1,j)) chkmax(rr[i][j],i+j+1);
		else if(kkd[i+j+1]!=mp(i+1,j))chkmax(rr[i][j],rr[i+1][j]);
	}
	F(i,1,n+m) ddsum[i]=max(ddsum[i-1],dd[kkd[i].x][kkd[i].y]);
	F(i,1,n+m) rrsum[i]=max(rrsum[i-1],rr[kkr[i].x][kkr[i].y]);
	F(i,1,n+m) rdsum[i]=max(rdsum[i-1],dd[kkr[i].x][kkr[i].y]);
	F(i,1,n+m) drsum[i]=max(drsum[i-1],rr[kkd[i].x][kkd[i].y]);
	F(i,2,n+m)
	F(j,2,n+m)
	{
	  	if(cnt[i]==1 || cnt[j]==1) continue;
	//	cout<<i<<"-"<<j<<":"<<rdsum[i-1]<<" "<<rrsum[i-1]<<" "<<ddsum[j-1]<<" "<<drsum[j-1]<<'\n';
		if(max(rdsum[i-1],ddsum[j-1])>j || max(drsum[j-1],rrsum[i-1])>i) continue;
		ans++;
	}
	cout<<ans<<'\n';
}
/*#include<bits/stdc++.h>
#define ll long long
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
const int N=3009;
char s[N][N];
int _1[N][N],_2[N][N];
int dd[N][N],dr[N][N],rr[N][N],rd[N][N];
int rrsum[2*N];
int drsum[2*N];
int rdsum[2*N];
int ddsum[2*N];
ll ans,num;
int cnt[2*N];
int n,m;
pii kkr[2*N],kkd[2*N];
void solve()
{
  	int x=1,y=1;
	kkr[2]=kkd[2]=mp(1,1);
	while(x!=n||y!=m)
	{
	  	if(x<n && s[x+1][y]=='.') ++x;
		else ++y;
		kkd[x+y]=mp(x,y);
	}
	x=y=1;
	while(x!=n||y!=m)
	{
	  	if(y<m && s[x][y+1]=='.') ++y;
		else ++x;
		kkr[x+y]=mp(x,y);
	}
}
void chkmax(int &a,int b)
{
  	if(b>a) a=b;
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m;
	F(i,1,n)cin>>s[i]+1;
	_1[1][1]=s[1][1]=='.';F(i,1,n)F(j,1,m) if(s[i][j]=='.') _1[i][j]|=_1[i][j-1]|_1[i-1][j];
	_2[n][m]=s[n][m]=='.';G(i,n,1)G(j,m,1) if(s[i][j]=='.') _2[i][j]|=_2[i][j+1]|_2[i+1][j];
	F(i,1,n)F(j,1,m)if(s[i][j]=='.'&&!(_1[i][j]&&_2[i][j]))s[i][j]='^';
	F(i,1,n)F(j,1,m)cnt[i+j]+=s[i][j]=='.',num+=s[i][j]!='*';
	if(s[1][1]!='.')
	{
	  	cout<<num*(num-1)/2<<'\n';
		return 0;
	}
	F(i,2,n+m) if(cnt[i]==1) ans+=--num;
	solve();
	G(i,n,1)G(j,m,1)
	{
	  	if(s[i][j]!='.') continue;
		if(kkd[i+j+1]==mp(i,j+1)) dd[i][j]=i+j+1;
		else if(kkr[i+j+1]!=mp(i,j+1))chkmax(dd[i][j],dd[i][j+1]);
		if(kkd[i+1+j]==mp(i+1,j)) chkmax(dd[i][j],i+j+1);
		else if(kkr[i+j+1]!=mp(i+1,j))chkmax(dd[i][j],dd[i+1][j]);
	}
	G(i,n,1)G(j,m,1)
	{
	  	if(s[i][j]!='.') continue;
		if(kkr[i+j+1]==mp(i,j+1)) rr[i][j]=i+j+1;
		else if(kkd[i+j+1]!=mp(i,j+1))chkmax(rr[i][j],rr[i][j+1]);
		if(kkr[i+1+j]==mp(i+1,j)) chkmax(rr[i][j],i+j+1);
		else if(kkd[i+j+1]!=mp(i+1,j))chkmax(rr[i][j],rr[i+1][j]);
	}
	F(i,1,n+m) ddsum[i]=max(ddsum[i-1],dd[kkd[i].x][kkd[i].y]);
	F(i,1,n+m) rrsum[i]=max(rrsum[i-1],rr[kkr[i].x][kkr[i].y]);
	F(i,1,n+m) rdsum[i]=max(rdsum[i-1],dd[kkr[i].x][kkr[i].y]);
	F(i,1,n+m) drsum[i]=max(drsum[i-1],rr[kkd[i].x][kkd[i].y]);
	F(i,2,n+m)
	F(j,2,n+m)
	{
	  	if(cnt[i]==1 || cnt[j]==1) continue;
	//	cout<<i<<"-"<<j<<":"<<rdsum[i-1]<<" "<<rrsum[i-1]<<" "<<ddsum[j-1]<<" "<<drsum[j-1]<<'\n';
		if(max(rdsum[i-1],ddsum[j-1])>j || max(drsum[j-1],rrsum[i-1])>i) continue;
		ans++;
	}
	cout<<ans<<'\n';
}#include<bits/stdc++.h>
#define ll long long
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
const int N=3009;
char s[N][N];
int _1[N][N],_2[N][N];
int dd[N][N],dr[N][N],rr[N][N],rd[N][N];
int rrsum[2*N];
int drsum[2*N];
int rdsum[2*N];
int ddsum[2*N];
ll ans,num;
int cnt[2*N];
int n,m;
pii kkr[2*N],kkd[2*N];
void solve()
{
  	int x=1,y=1;
	kkr[2]=kkd[2]=mp(1,1);
	while(x!=n||y!=m)
	{
	  	if(x<n && s[x+1][y]=='.') ++x;
		else ++y;
		kkd[x+y]=mp(x,y);
	}
	x=y=1;
	while(x!=n||y!=m)
	{
	  	if(y<m && s[x][y+1]=='.') ++y;
		else ++x;
		kkr[x+y]=mp(x,y);
	}
}
void chkmax(int &a,int b)
{
  	if(b>a) a=b;
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m;
	F(i,1,n)cin>>s[i]+1;
	_1[1][1]=s[1][1]=='.';F(i,1,n)F(j,1,m) if(s[i][j]=='.') _1[i][j]|=_1[i][j-1]|_1[i-1][j];
	_2[n][m]=s[n][m]=='.';G(i,n,1)G(j,m,1) if(s[i][j]=='.') _2[i][j]|=_2[i][j+1]|_2[i+1][j];
	F(i,1,n)F(j,1,m)if(s[i][j]=='.'&&!(_1[i][j]&&_2[i][j]))s[i][j]='^';
	F(i,1,n)F(j,1,m)cnt[i+j]+=s[i][j]=='.',num+=s[i][j]!='*';
	if(s[1][1]!='.')
	{
	  	cout<<num*(num-1)/2<<'\n';
		return 0;
	}
	F(i,2,n+m) if(cnt[i]==1) ans+=--num;
	solve();
	G(i,n,1)G(j,m,1)
	{
	  	if(s[i][j]!='.') continue;
		if(kkd[i+j+1]==mp(i,j+1)) dd[i][j]=i+j+1;
		else if(kkr[i+j+1]!=mp(i,j+1))chkmax(dd[i][j],dd[i][j+1]);
		if(kkd[i+1+j]==mp(i+1,j)) chkmax(dd[i][j],i+j+1);
		else if(kkr[i+j+1]!=mp(i+1,j))chkmax(dd[i][j],dd[i+1][j]);
	}
	G(i,n,1)G(j,m,1)
	{
	  	if(s[i][j]!='.') continue;
		if(kkr[i+j+1]==mp(i,j+1)) rr[i][j]=i+j+1;
		else if(kkd[i+j+1]!=mp(i,j+1))chkmax(rr[i][j],rr[i][j+1]);
		if(kkr[i+1+j]==mp(i+1,j)) chkmax(rr[i][j],i+j+1);
		else if(kkd[i+j+1]!=mp(i+1,j))chkmax(rr[i][j],rr[i+1][j]);
	}
	F(i,1,n+m) ddsum[i]=max(ddsum[i-1],dd[kkd[i].x][kkd[i].y]);
	F(i,1,n+m) rrsum[i]=max(rrsum[i-1],rr[kkr[i].x][kkr[i].y]);
	F(i,1,n+m) rdsum[i]=max(rdsum[i-1],dd[kkr[i].x][kkr[i].y]);
	F(i,1,n+m) drsum[i]=max(drsum[i-1],rr[kkd[i].x][kkd[i].y]);
	F(i,2,n+m)
	F(j,2,n+m)
	{
	  	if(cnt[i]==1 || cnt[j]==1) continue;
	//	cout<<i<<"-"<<j<<":"<<rdsum[i-1]<<" "<<rrsum[i-1]<<" "<<ddsum[j-1]<<" "<<drsum[j-1]<<'\n';
		if(max(rdsum[i-1],ddsum[j-1])>j || max(drsum[j-1],rrsum[i-1])>i) continue;
		ans++;
	}
	cout<<ans<<'\n';
}*/

Details

answer.code: In function ‘int main()’:
answer.code:49:20: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   49 |         F(i,1,n)cin>>s[i]+1;
      |                 ~~~^~~~~~~~
      |                 |        |
      |                 |        char*
      |                 std::istream {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,
                 from answer.code:1:
/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:49:26: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   49 |         F(i,1,n)cin>>s[i]+1;
      |                      ~~~~^~
/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:49:26: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   49 |         F(i,1,n)cin>>s[i]+1;
      |                      ~~~~^~
      |                          |
      |                          char*
answer.code:49:26: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s[i])) + 1)’ 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:49:26: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   49 |         F(i,1,n)cin>>s[i]+1;
      |                      ~~~~^~
      |                          |
      |                          char*
answer.code:49:26: error: cannot bind rvalue ‘(long long int)(((char*)(& s[i])) + 1)’ 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:49:26: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   49 |         F(i,1,n)cin>>s[i]+1;
      |                      ~~~~^~
      |                          |
      |                          char*
answer.code:49:26: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& s[i])) + 1)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:49:26: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   49 |         F(i,1,n)cin>>s[i]+1;
      |                      ~~~~^~
      |                          |
      |                          char*
answer.code:49:26: error: cannot bind rvalue ‘(long int)(((char*)(& s[i])) + 1)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:184:7: note:   conversion of argument 1 would be ill-formed:
answer.code:49:26: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   49 |         F(i,1,n)cin>>s[i]+1;
    ...