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;
#define pb push_back();
#define ff find_first;
#define ss second;
std::vector<int> r, c;
int h,w;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
h = H;
w = W;
r = R;
c = C;
}
int swap_seats(int a, int b) {
swap(r[a], r[b]);
swap(c[a], c[b]);
int ans = 1;
int r_mn_r = r[0];
int r_mn_c = c[0];
//
int c_mn_r = r[0];
int c_mn_c = c[0];
//
int r_mx_r = r[0];
int r_mx_c = c[0];
//
int c_mx_r = r[0];
int c_mx_c = c[0];
//
for(int i = 1; i < h * w; i ++) {
if(r[i] < r_mn_r) {
r_mn_r = r[i];
r_mn_c = c[i];
}
else if(r[i] == r_mn_r) {
r_mn_c = min(r_mn_c, c[i]);
}
//
if(c[i] < c_mn_c) {
c_mn_c = c[i];
c_mn_r = r[i];
}
else if(c[i] == c_mn_c) {
c_mn_r = min(c_mn_r, r[i]);
}
//
if(r[i] > r_mx_r) {
r_mx_r = r[i];
r_mx_c = c[i];
}
else if(r[i] == r_mx_r) {
r_mx_c = max(r_mx_c, c[i]);
}
//
if(c[i] > c_mx_c) {
c_mx_c = c[i];
c_mx_r = r[i];
}
else if(c[i] == c_mx_c) {
c_mx_r = max(c_mx_r, r[i]);
}
if(r_mn_r == c_mn_r && r_mn_c == c_mn_c && r_mx_r == c_mx_r && r_mx_c == c_mx_c && (r_mx_r - r_mn_r + 1) * (c_mx_c - c_mn_c + 1) == i + 1) ans ++;
}
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... |