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;
//vector<vector<int>> gr;
vector<int> r,c;
int h,w,n;
int get(){
int a = r[0],b=c[0],x= r[0],y=c[0];
int ans = 1;
for(int i=1;i<n;i++){
int le = r[i], ri = c[i];
//cerr<<le<<" "<<ri<<'\n';
if(le < a)a = le;
if(le > x)x = le;
if(ri < b)b = ri;
if(ri > y)y = ri;
//cerr << i<<": "<<a<<" "<<b<<" "<<x<<" "<<y<<'\n';
ans += (x-a+1) * (y-b+1) == i+1;
i = max(i,(x-a+1) * (y-b+1)-2);
}
return ans;
}
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
h = H,w= W,n = H*W;
r = R;
c = C;
}
int swap_seats(int a, int b) {
swap(r[a],r[b]);
swap(c[a],c[b]);
return get();
}
# | 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... |