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;
int M,N;
int r[10005],c[10005];
int last=0;
int maxr[1000005],maxc[1000005],minr[1000005],minc[1000005];
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
M=H,N=W;
for(int i=0;i<M*N;i++){
r[i]=R[i];
c[i]=C[i];
}
for(int i=0;i<M*N;i++){
if(i==0){
maxr[0]=minr[0]=r[i];
maxc[0]=minc[0]=c[i];
}
else{
maxr[i]=max(maxr[i-1],r[i]);
maxc[i]=max(maxc[i-1],c[i]);
minr[i]=min(minr[i-1],r[i]);
minc[i]=min(minc[i-1],c[i]);
}
if((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i+1) last++;
}
}
int swap_seats(int a, int b){
if(a>b) swap(a,b);
for(int i=a;i<=b;i++){
if((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i+1) last--;
}
swap(r[a],r[b]);
swap(c[a],c[b]);
for(int i=a;i<=b;i++){
if(i==0){
maxr[0]=minr[0]=r[i];
maxc[0]=minc[0]=c[i];
}
else{
maxr[i]=max(maxr[i-1],r[i]);
maxc[i]=max(maxc[i-1],c[i]);
minr[i]=min(minr[i-1],r[i]);
minc[i]=min(minc[i-1],c[i]);
}
if((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i+1) last++;
}
return last;
}
# | 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... |