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;
vector<int> c;
vector<int> minr;
vector<int> minc;
vector<int> maxr;
vector<int> maxc;
int n;
int tot = 0;
int INF = 1e9;
void display(vector<int> &v){
for (int i : v){
cout<<i<<' ';
}cout<<'\n'<<'\n';
}
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
r=R;
c=C;
n=H*W;
minr.resize(n+1,INF);
minc.resize(n+1,INF);
maxr.resize(n+1,-INF);
maxc.resize(n+1,-INF);
for (int i = 1; i<=n; i++){
minr[i]=min(minr[i-1],r[i-1]);
maxr[i]=max(maxr[i-1],r[i-1]);
minc[i]=min(minc[i-1],c[i-1]);
maxc[i]=max(maxc[i-1],c[i-1]);
if ((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i){
tot++;
}
}
//display(minr);display(maxr);
//display(minc);display(maxc);
}
int swap_seats(int a, int b) {
a++;b++;
if (b<a){
swap(a,b);
}
swap(r[a-1],r[b-1]);
swap(c[a-1],c[b-1]);
for (int i = a; i<=b; i++){
if ((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i){
tot--;
}
minr[i]=min(minr[i-1],r[i-1]);
maxr[i]=max(maxr[i-1],r[i-1]);
minc[i]=min(minc[i-1],c[i-1]);
maxc[i]=max(maxc[i-1],c[i-1]);
if ((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i){
tot++;
}
}
//display(minr);display(maxr);
//display(minc);display(maxc);
return tot;
}
# | 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... |