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 <bits/stdc++.h>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 2e9+5
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9;
const int nax = 1e5+5;
#include "seats.h"
vi r,c;
int w,h, cur = 0;
vi mn1, mx1, mn2, mx2, res;
void give_initial_chart(int H, int W, vi R, vi C) {
r = R;
c = C;
w = W;
h = H;
mn1.assign(w*h, INF);
mx1.assign(w*h, 0);
mn2.assign(w*h,INF);
mx2.assign(w*h, 0);
res.assign(w*h,0);
for (int i = 0; i < w*h; ++i)
{
if(i > 0){
mn1[i] = min(mn1[i-1], r[i]);
mx1[i] = max(mx1[i-1], r[i]);
mn2[i] = min(mn2[i-1], c[i]);
mx2[i] = max(mx2[i-1], c[i]);
} else mn1[i] = mx1[i] = r[i], mn2[i] = mx2[i] = c[i];
if( (mx1[i]-mn1[i]+1) * (mx2[i]-mn2[i]+1) == i+1) {
res[i] = 1;
cur++;
}
}
}
int swap_seats(int a, int b) {
if(a > b) swap(a,b);
swap(r[a], r[b]);
swap(c[a], c[b]);
for (int i = a; i <= b; ++i)
{
if(i > 0){
mn1[i] = min(mn1[i-1], r[i]);
mx1[i] = max(mx1[i-1], r[i]);
mn2[i] = min(mn2[i-1], c[i]);
mx2[i] = max(mx2[i-1], c[i]);
} else mn1[i] = mx1[i] = r[i], mn2[i] = mx2[i] = c[i];
if( (mx1[i]-mn1[i]+1) * (mx2[i]-mn2[i]+1) == i+1) {
if(res[i] == 0) res[i] = 1, cur++;
} else if(res[i] == 1) res[i] = 0, cur--;
}
return cur;
}
# | 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... |