This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "seats.h"
using namespace std;
typedef long long ll;
int n,h,w;
vector<array<int,2>> v;
vector<int> ar,br,ac,bc;
int res=0;
int ok(int i){return ((br[i]-ar[i]+1)*(bc[i]-ac[i]+1)==i+1);}
void give_initial_chart(int nh,int nw,vector<int> r,vector<int> c)
{
h=nh;
w=nw;
n=h*w;
v.assign(n,{0,0});
for(int i=0;i<n;i++) v[i]={r[i],c[i]};
ar.assign(n,v[0][0]);
br.assign(n,v[0][0]);
ac.assign(n,v[0][1]);
bc.assign(n,v[0][1]);
res=ok(0);
for(int i=1;i<n;i++)
{
ar[i]=min(ar[i-1],v[i][0]);
br[i]=max(br[i-1],v[i][0]);
ac[i]=min(ac[i-1],v[i][1]);
bc[i]=max(bc[i-1],v[i][1]);
res+=ok(i);
}
}
int swap_seats(int a,int b)
{
swap(v[a],v[b]);
for(int i=a;i<=b;i++)
{
res-=ok(i);
ar[i]=min((i>0?ar[i-1]:n),v[i][0]);
br[i]=max((i>0?br[i-1]:0),v[i][0]);
ac[i]=min((i>0?ac[i-1]:n),v[i][1]);
bc[i]=max((i>0?bc[i-1]:0),v[i][1]);
res+=ok(i);
}
return res;
}
//int main()
//{
//
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |