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 <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
vpi pos;
int h, w, n;
void give_initial_chart(int H, int W, vi R, vi C) {
for (int i = 0; i < H*W; i++)
{
pos.push_back({ R[i], C[i] });
}
h = H, w = W, n = H * W;
}
int swap(int a, int b) {
swap(pos[a], pos[b]);
int k = 1;
int minc, minr, maxc, maxr;
minr = maxr = pos[0].first;
minc = maxc = pos[0].second;
for (int i = 1; i < n; i++)
{
minr = min(minr, pos[i].first);
maxr = max(maxr, pos[i].first);
minc = min(minc, pos[i].second);
maxc = max(maxc, pos[i].second);
int s = (maxc - minc + 1) * (maxr - minr + 1);
if (s == i + 1) {
k++;
}
else {
i = min(i, s - 2);
}
}
return k;
}
int swap_seats(int a, int b) {
return swap(a, b);
}
# | 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... |