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_seats(int a, int b) {
pi temp = pos[a];
pos[a] = pos[b];
pos[b] = temp;
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);
if ((maxc - minc + 1) * (maxr - minr + 1) == i + 1) {
k++;
}
}
return k;
}
# | 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... |