QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#506788 | #5052. Rectangle Flip 2 | Nahidameow | WA | 0ms | 3832kb | C++20 | 1.6kb | 2024-08-05 21:57:10 | 2024-08-05 21:57:10 |
Judging History
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(d>=u)break;
ans-=u-d-1;
}
}
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: 3592kb
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: 3832kb
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:
180 144 120 111 89 84 79 73 64 61 57 50 45 43 40 37 33 32 29 27 25 23 21 20 19
result:
wrong answer 1st numbers differ - expected: '153', found: '180'