QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#301464#5052. Rectangle Flip 2zzuqyWA 0ms7968kbC++141.6kb2024-01-09 22:30:592024-01-09 22:31:00

Judging History

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

  • [2024-01-09 22:31:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7968kb
  • [2024-01-09 22:30:59]
  • 提交

answer

#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<deque>
#define ll long long
#define mod 998244353
#define sc(A) scanf("%d",&A)
#define rep(A,B,C) for(int C=A;C<=B;++C)
#define fep(A,B,C) for(int C=A;C>=B;--C)
#define put(x) printf("%d\n",x)
#define db double
using namespace std;
const int MAXN=510,maxn=77;
int n,m,x,maxx=62,top;
int a[MAXN][MAXN];
int f[MAXN][MAXN],F[MAXN];
int g[MAXN][MAXN],G[MAXN];
ll w[MAXN*MAXN];
struct wy{int l,r;}s[MAXN*MAXN];
signed main() 
{
	//freopen("1.in","r",stdin);
	sc(n);sc(m);
	
	rep(1,n,i)rep(1,m,j)
	{
		sc(s[(i-1)*m+j].l);
		sc(s[(i-1)*m+j].r);
	}

	fep(n*m,1,W)
	{
		int x=s[W].l;
		int y=s[W].r;
		int cnt=0;
		a[x][y]=1;
		while(a[x-cnt-1][y])++cnt;
		f[x][y]=cnt;
		cnt=0;
		while(a[x+cnt+1][y])++cnt;
		g[x][y]=cnt;

		F[y]=f[x][y];
		int minn=f[x][y];
		rep(y+1,m,j)
		{
			minn=min(minn,f[x][j]);
			F[j]=minn;
		}
		minn=f[x][y];
		fep(y-1,1,j)
		{
			minn=min(minn,f[x][j]);
			F[j]=minn;
		}
		G[y]=g[x][y];
		minn=g[x][y];
		rep(y+1,m,j)
		{
			minn=min(minn,g[x][j]);
			G[j]=minn;
		}
		minn=g[x][y];
		fep(y-1,1,j)
		{
			minn=min(minn,g[x][j]);
			G[j]=minn;
		}
		ll ans=0;
		fep(y,1,i)
		{
			if(!a[x][i])break;
			rep(y,m,j)
			{
				if(!a[x][j])break;
				int L=min(F[i],F[j]);
				int R=min(G[i],G[j]);
				ans+=(L+1)*(R+1);
			}
		}
		w[W]=w[W+1]+ans;
		
		cnt=0;
		while(a[x-1-cnt][y])f[x-1-cnt][y]=f[x-cnt][y]+1,++cnt;
		cnt=0;
		while(a[x+1+cnt][y])g[x+1+cnt][y]=g[x+cnt][y]+1,++cnt;
	}
	rep(1,n*m,i)printf("%lld\n",w[i+1]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 7968kb

input:

2 2
1 1
2 1
1 2
2 2

output:

5
3
1
0

result:

ok 4 number(s): "5 3 1 0"

Test #2:

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

input:

5 5
3 2
2 5
4 3
5 5
2 1
3 5
1 5
3 3
3 4
3 1
4 2
1 4
2 2
4 1
2 3
1 3
5 1
2 4
5 2
4 5
1 1
5 3
4 4
5 4
1 2

output:

133
113
89
82
68
63
58
52
43
40
36
31
26
24
21
18
14
13
10
8
6
4
2
1
0

result:

wrong answer 1st numbers differ - expected: '153', found: '133'