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>
#define N 1000005
using namespace std;
struct node{
int l1 = 1e9,r1 = 0;
int l2 = 1e9,r2 = 0;
int size(){
return (r1 - l1 + 1) * (r2 - l2 + 1);
}
};
node merge(node a,node b){
node ret;
ret.l1 = min(a.l1,b.l1);
ret.r1 = max(a.r1,b.r1);
ret.l2 = min(a.l2,b.l2);
ret.r2 = max(a.r2,b.r2);
return ret;
}
node v[N];
int cnt = 0;
vector<int> r,c;
void give_initial_chart(int h, int w, vector<int> R, vector<int> C) {
r = R;
c = C;
for(int i = 0;i<h*w;i++){
v[i] = {r[i],r[i],c[i],c[i]};
if(i)
v[i] = merge(v[i],v[i-1]);
if(v[i].size() == i+1)
cnt++;
}
}
int swap_seats(int a, int b) {
if(a > b)swap(a,b);
for(int i = a;i<=b;i++){
if(v[i].size() == i+1)
cnt--;
}
swap(r[a],r[b]);
swap(c[a],c[b]);
for(int i = a;i<=b;i++){
v[i] = {r[i],r[i],c[i],c[i]};
if(i)
v[i] = merge(v[i],v[i-1]);
if(v[i].size() == i+1)
cnt++;
}
return cnt;
}
# | 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... |