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>
using namespace std;
const int maxn = 1e6 + 10;
int n, h, w;
vector<int> r, c;
int MxC[4*maxn], MxR[4*maxn], MnC[4*maxn], MnR[4*maxn];
int Now = 0;
bool isGood(int idx){
int r1 = MnR[idx], r2 = MxR[idx], c1 = MnC[idx], c2 = MxC[idx];
int Size = (r2-r1+1) * (c2-c1+1);
if (Size == idx+1)
return true;
return false;
}
void give_initial_chart(int H, int W, vector<int> R, vector<int> C){
h = H, w = W, r = R, c = C;
n = h*w;
for (int i = 0; i < n; i++){
MxC[i] = (i == 0 ? C[i] : max(MxC[i-1],C[i]));
MnC[i] = (i == 0 ? C[i] : min(MnC[i-1],C[i]));
MxR[i] = (i == 0 ? R[i] : max(MxR[i-1],R[i]));
MnR[i] = (i == 0 ? R[i] : min(MnR[i-1],R[i]));
Now += isGood(i);
}
}
int swap_seats(int a, int b){
if (a > b)
swap(a,b);
swap(r[a],r[b]);
swap(c[a],c[b]);
for (int i = a; i < b; i++){
Now -= isGood(i);
MxC[i] = (i == 0 ? c[i] : max(MxC[i-1],c[i]));
MnC[i] = (i == 0 ? c[i] : min(MnC[i-1],c[i]));
MxR[i] = (i == 0 ? r[i] : max(MxR[i-1],r[i]));
MnR[i] = (i == 0 ? r[i] : min(MnR[i-1],r[i]));
Now += isGood(i);
}
return Now;
}
# | 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... |