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;
#define ll int
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 1e6+5;
const ll INF = 1e9+7;
vector<pii>lim1(MAXN);
vector<pii>lim2(MAXN);
bitset<1000004>ok;
std::vector<int> r;
std::vector<int> c;
ll h,w;
void give_initial_chart(int H, int W,std::vector<int> R,std::vector<int> C){
r = R;
c = C;
h=H;
w=W;
ll k,area;
for(k=0;k<H*W;k++){
if(k==0){
lim1[0]={R[0],R[0]};
lim2[0]={C[0],C[0]};
}else{
//update
lim1[k].first=min(lim1[k-1].first,R[k]);
lim1[k].second=max(lim1[k-1].second,R[k]);
lim2[k].first=min(lim2[k-1].first,C[k]);
lim2[k].second=max(lim2[k-1].second,C[k]);
}
//area
area = lim1[k].second-lim1[k].first+1;
area*=(lim2[k].second-lim2[k].first+1);
ok[k]=0;
if(area==k+1){
ok[k]=1;
}
}
}
int swap_seats(int a, int b) {
swap(r[a],r[b]);
swap(c[a],c[b]);
ll k,area;
if(a>b)swap(a,b);
for(k=a;k<=b;k++){
if(k==0){
lim1[0]={r[0],r[0]};
lim2[0]={c[0],c[0]};
}else{
//update
lim1[k].first=min(lim1[k-1].first,r[k]);
lim1[k].second=max(lim1[k-1].second,r[k]);
lim2[k].first=min(lim2[k-1].first,c[k]);
lim2[k].second=max(lim2[k-1].second,c[k]);
}
//area
area = lim1[k].second-lim1[k].first+1;
area*=(lim2[k].second-lim2[k].first+1);
ok[k]=0;
if(area==k+1){
ok[k]=1;
}
}
return ok.count();
}
# | 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... |