# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152685 | Segtree | Seats (IOI18_seats) | C++14 | 0 ms | 0 KiB |
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<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define N 10010
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll h,w,r[N],c[N];
void give_initial_chart(int H,int W,vector<ll> R,vector<ll> C){
h=H,w=W;
for(int i=1;i<=h*w;i++)r[i]=R[i];
for(int i=1;i<=h*w;i++)c[i]=C[i];
}
int swap_seats(int a,int b){
if(h*w>N)return 0;
swap(r[a],r[b]);
swap(c[a],c[b]);
ll xl=1e17,xr=-1e17,yl=1e17,yr=-1e17;
ll ans=0;
for(int k=1;k<=h*w;k++){
chmin(xl,r[k]);
chmax(xr,r[k]);
chmin(yl,c[k]);
chmax(yr,c[k]);
if((xr-xl+1)*(yr-yl+1)==k)ans++;
}
return ans;
}/*
int main(){
return 0;
}*/