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 "seats.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> r, c, rmi, rma, cmi, cma, v;
int s=0, n;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
r=R;
rmi=R;
rma=R;
c=C;
cmi=C;
cma=C;
n=H*W;
s=1;
v.push_back(1);
for(int i=1; i<n; i++){
rmi[i]=min(r[i], rmi[i-1]);
rma[i]=max(r[i], rma[i-1]);
cmi[i]=min(c[i], cmi[i-1]);
cma[i]=max(c[i], cma[i-1]);
if((rma[i]-rmi[i]+1)*(cma[i]-cmi[i]+1)==i+1){
s++;
v.push_back(1);
}
else v.push_back(0);
}
return;
}
int swap_seats(int a, int b) {
if(a>b)swap(a, b);
swap(r[a], r[b]);
swap(c[b], c[a]);
a+=(a==0);
for(int i=a; i<b; i++){
s-=v[i];
rmi[i]=min(r[i], rmi[i-1]);
rma[i]=max(r[i], rma[i-1]);
cmi[i]=min(c[i], cmi[i-1]);
cma[i]=max(c[i], cma[i-1]);
if((rma[i]-rmi[i]+1)*(cma[i]-cmi[i]+1)==i+1){
s++;
v[i]=1;
}
else v[i]=0;
}
return s;
}
# | 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... |