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;
typedef long long ll;
const ll N=1e6+10;
ll r[N],c[N],h,w;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
for(ll i=0;i<H*W;i++) r[i]=R[i],c[i]=C[i];
h=H,w=W;
}
int swap_seats(int a, int b) {
swap(r[a],r[b]),swap(c[a],c[b]);
ll ans=1,a1=c[0],a2=c[0],b1=r[0],b2=r[0];
for(ll i=1;i<h*w;i++){
a1=min(a1,c[i]),a2=max(a2,c[i]);
b1=min(b1,r[i]),b2=max(b2,r[i]);
if( (a2-a1+1)*(b2-b1+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... |