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;
int r, c;
vector<pair<int, int>> where;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
ios::sync_with_stdio(0);
cin.tie(0);
r = H;
c = W;
where.resize(r * c);
for (int i = 0; i < r * c; i++) {
where[i] = {R[i], C[i]};
}
}
int solve() {
int res = 0;
int min_row = 1e9;
int max_row = -1e9;
int min_column = 1e9;
int max_column = -1e9;
for (int i = 0; i < r * c; i++) {
min_row = min(min_row, where[i].first);
max_row = max(max_row, where[i].first);
min_column = min(min_column, where[i].second);
max_column = max(max_column, where[i].second);
res += (((max_row - min_row + 1) * (max_column - min_column + 1)) == (i + 1));
}
return res;
}
int swap_seats(int a, int b) {
swap(where[a], where[b]);
return solve();
}
# | 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... |