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;
namespace {
const int MX=1e6+5;
const array<int,4> inf={(int)1e9,0,(int)1e9,0};
int H,W;
array<int,4> arr[MX];
}
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
::H=H, ::W=W;
for(int i=0;i<H*W;i++) {
arr[i]={R[i],R[i],C[i],C[i]};
}
}
int swap_seats(int a, int b) {
swap(arr[a],arr[b]);
int ans=0;
int L0=1e9,R0=0,L1=1e9,R1=0;
for(int i=0;i<H*W;i++) {
L0=min(L0,arr[i][0]);
L1=min(L1,arr[i][2]);
R0=max(R0,arr[i][1]);
R1=max(R1,arr[i][3]);
if((R1-R0+1)*(L1-L0+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... |