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;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
int H, W;
std::vector<int> R, C;
void give_initial_chart(int _H, int _W, std::vector<int> _R, std::vector<int> _C)
{
H = _H, W = _W;
R = _R, C = _C;
}
int swap_seats(int a, int b)
{
swap(R[a], R[b]), swap(C[a], C[b]);
int rmax = R[0], rmin = R[0];
int cmax = C[0], cmin = C[0];
int ans = 0;
for (int k = 0; k < H * W; ++k)
{
rmax = max(rmax, R[k]);
rmin = min(rmin, R[k]);
cmax = max(cmax, C[k]);
cmin = min(cmin, C[k]);
int area = (rmax - rmin + 1) * (cmax - cmin + 1);
if (area == k + 1)
++ans;
assert(area >= k);
}
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... |