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>
#include "seats.h"
using namespace std;
constexpr static int MXN = 1e4 + 5;
constexpr static int INF = 1e6;
vector<int> r, c;
int mnr[MXN], mxr[MXN], mnc[MXN], mxc[MXN];
int h, w, n;
int counter;
void create_table()
{
counter = 0;
mnr[0] = INF;
mxr[0] = -INF;
mnc[0] = INF;
mxr[0] = -INF;
for (int i = 1; i <= n; i++)
{
mnr[i] = min(mnr[i-1], r[i-1]);
mxr[i] = max(mxr[i-1], r[i-1]+1);
mnc[i] = min(mnc[i-1], c[i-1]);
mxc[i] = max(mxc[i-1], c[i-1]+1);
if ((mxr[i] - mnr[i]) * (mxc[i] - mnc[i]) == i)
counter++;
}
}
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
r = R, c = C;
h = H, w = W;
n = h*w;
}
int swap_seats(int a, int b) {
swap(r[a], r[b]);
swap(c[a], c[b]);
create_table();
return counter;
}
# | 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... |