#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
//#define int long long
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
int H, W;
const int mxh = 1e4, mxw = 1e4;
pii pos[10000];
void give_initial_chart(int H1, int W1, vi R, vi C) {
H = H1; W = W1;
for (int i = 0; i < H * W; i++) {
pos[i] = {R[i], C[i]};
}
}
int swap_seats(int a, int b) {
swap(pos[a], pos[b]);
pii tl = {1e18, 1e18}, br = {-1e18, -1e18};
int ans = 0;
for (int s = 0; s < H * W; s++) {
tl.fi = min(tl.fi, pos[s].fi);
tl.se = min(tl.se, pos[s].se);
br.fi = max(br.fi, pos[s].fi);
br.se = max(br.se, pos[s].se);
ans += ((br.fi - tl.fi + 1) * (br.se - tl.se + 1) == (s + 1));
}
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... |