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;
const int N = 1e6 + 5, INF = 1e9;
int n, m;
vector<int> x, y;
int lx[N], rx[N], ly[N], ry[N];
bool rect[N];
int ans = 0;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
n = H;
m = W;
x = R;
y = C;
lx[0] = INF;
rx[0] = -1;
ly[0] = INF;
ry[0] = -1;
for (int i = 1; i <= n * m; i++) {
lx[i] = min(lx[i - 1], x[i - 1]);
rx[i] = max(rx[i - 1], x[i - 1]);
ly[i] = min(ly[i - 1], y[i - 1]);
ry[i] = max(ry[i - 1], y[i - 1]);
if ((rx[i] - lx[i] + 1) * (ry[i] - ly[i] + 1) == i) {
rect[i] = 1;
ans++;
}
}
}
int swap_seats(int a, int b) {
swap(x[a], x[b]);
swap(y[a], y[b]);
for (int i = a + 1; i <= b + 1; i++) {
lx[i] = min(lx[i - 1], x[i - 1]);
rx[i] = max(rx[i - 1], x[i - 1]);
ly[i] = min(ly[i - 1], y[i - 1]);
ry[i] = max(ry[i - 1], y[i - 1]);
ans -= rect[i];
if ((rx[i] - lx[i] + 1) * (ry[i] - ly[i] + 1) == i) {
rect[i] = 1;
ans++;
}
else {
rect[i] = 0;
}
}
return ans;
}
# | 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... |