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>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
vector<int> row, col;
int h, w;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
row = R;
col = C;
h = H;
w = W;
}
int swap_seats(int A, int B) {
swap(row[A], row[B]);
swap(col[A], col[B]);
// cout << "=== " << A << ' ' << B << '\n';
// cout << row[A] << ' '<< col[A] << ' ' << row[B] << ' ' << col[B] << '\n';
int ans = 0, l = w-1, r = 0, t = h-1, b = 0;
for (int i = 0; i < h*w; i++) {
// cout << col[i] << ' ' << row[i] << '\n';
l = min(l, col[i]);
t = min(t, row[i]);
r = max(r, col[i]);
b = max(b, row[i]);
// cout << l << ' ' << r << '\n';
// cout << t << ' ' << b << '\n';
if (i+1 == (r-l+1)*(b-t+1)) {
// cout << i << ' ';
ans++;
}
}
// cout << "===\n";
// cout << '\n';
return ans;
}
/*
2 3 2
0 0
1 0
1 1
0 1
0 2
1 2
0 5
0 5
*/
# | 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... |