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 <algorithm>
template<typename T> bool ckmax(T& a, const T& b) {return b>a?a=b,1:0;}
template<typename T> bool ckmin(T& a, const T& b) {return b<a?a=b,1:0;}
const int INF = 0x3f3f3f3f;
int N;
std::vector<int> R, C;
void give_initial_chart(int H, int W, std::vector<int> _R, std::vector<int> _C) {
R=_R, C=_C;
N = H*W;
}
int ans()
{
int maxr=-1, minr=INF, maxc=-1, minc=INF, ans=0;
for(int i=0;i<N;++i)
{
ckmin(minr, R[i]);
ckmax(maxr, R[i]+1);
ckmin(minc, C[i]);
ckmax(maxc, C[i]+1);
if(i+1 == (maxr-minr)*(maxc-minc))
++ans;
}
return ans;
}
int swap_seats(int a, int b) {
std::swap(R[a], R[b]);
std::swap(C[a], C[b]);
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... |