QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506790#5052. Rectangle Flip 2NahidameowWA 0ms3848kbC++201.7kb2024-08-05 22:02:222024-08-05 22:02:27

Judging History

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

  • [2024-08-05 22:02:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-08-05 22:02:22]
  • 提交

answer

#include<bits/stdc++.h>
#define pd push_back
#define all(A) A.begin(),A.end()
#define lb lower_bound
#define ve std::vector
typedef long long ll;
typedef long long ll;
typedef __int128 Int;
typedef unsigned long long ul;
typedef long double LD;
bool FileIfstream(std::string name){
	std::ifstream f(name.c_str());
	return f.good();
}
namespace Math{
	ll QP(ll x,ll y,ll mod){ll ans=1;for(;y;y>>=1,x=x*x%mod)if(y&1)ans=ans*x%mod;return ans;}
	ll inv(ll x,ll mod){return QP(x,mod-2,mod);}
}
const int N=2e5+10;
const int mod=998244353;
void solve(){
	//don't forget to open long long
	int n,m;std::cin>>n>>m;
	ve<ve<int>>L(n+1,ve<int>(m+1,0));
	ve<ve<int>>R(n+1,ve<int>(m+1,m+1));
	ll ans=n*(n+1)/2*m*(m+1)/2;
	for(int i=1;i<=n*m;i++){
		int x,y;std::cin>>x>>y;
		for(int l=x,u1=m+1,d1=0;l>=1&&d1<u1;l--){
			u1=std::min(u1,R[l][y]);
			d1=std::max(d1,L[l][y]);
			for(int r=x,u2=m+1,d2=0;r<=n&&d2<u2;r++){
				u2=std::min(u1,R[r][y]);
				d2=std::max(d1,L[r][y]);
				int d=std::max(d1,d2),u=std::min(u1,u2);
				if(u<=y||d>=y)break;
				ans-=1ll*(u-y)*(y-d);
			}
		}
		for(int j=y;j<=m;j++)
			L[x][j]=std::max(L[x][j],y);
		for(int j=1;j<=y;j++)
			R[x][j]=std::min(R[x][j],y);
		std::cout<<ans<<'\n';
	}
}
int main(){
#ifndef ONLINE_JUDGE
	if(!FileIfstream("IO.in")){
		freopen("IO.in","w",stdout);
		return 0;
	}
	freopen("IO.in","r",stdin);
	freopen("IO.out","w",stdout);
#endif
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	int T=1;
	//std::cin>>T;
	while(T--)solve();

#ifndef ONLINE_JUDGE
	std::cerr<<std::fixed<<std::setprecision(10)<<1.0*clock()/CLOCKS_PER_SEC<<'\n';
#endif

	return 0;
}






Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3848kb

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:

153
117
85
76
54
49
44
38
29
26
22
15
10
8
5
2
-2
-3
-6
-8
-10
-12
-14
-15
-16

result:

wrong answer 2nd numbers differ - expected: '125', found: '117'