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;
const int maxn = 1e6 + 10;
vector<int> l1(maxn, maxn), l2(maxn, -maxn), c1(maxn, maxn), c2(maxn, -maxn), marc(maxn);
vector<int> i, j;
int n, m;
int resp;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
i = R; j = C;
n = H, m = W;
for( int k = 1; k <= H*W; k++ ){
l1[k] = min(l1[k - 1], i[k - 1] );
l2[k] = max(l2[k - 1], i[k - 1] );
c1[k] = min(c1[k - 1], j[k - 1] );
c2[k] = max(c2[k - 1], j[k - 1] );
if( (l2[k] - l1[k] + 1)*(c2[k] - c1[k] + 1) == k ){ marc[k] = 1; resp++; }
}
}
int swap_seats(int a, int b) {
swap( i[a], i[b] ); swap( j[a], j[b] );
// for( int k = a + 1; k <= b + 1; k++ ){
// if( marc[k] ){ marc[k] = 0; resp--; }
// l1[k] = min(l1[k - 1], i[k - 1] );
// l2[k] = max(l2[k - 1], i[k - 1] );
// c1[k] = min(c1[k - 1], j[k - 1] );
// c2[k] = max(c2[k - 1], j[k - 1] );
// if( (l2[k] - l1[k] + 1)*(c2[k] - c1[k] + 1) == k ){ marc[k] = 1; resp++; }
// }
int resp = 0;
for( int k = 1; k <= n*m; k++ ){
l1[k] = min(l1[k - 1], i[k - 1] );
l2[k] = max(l2[k - 1], i[k - 1] );
c1[k] = min(c1[k - 1], j[k - 1] );
c2[k] = max(c2[k - 1], j[k - 1] );
if( (l2[k] - l1[k] + 1)*(c2[k] - c1[k] + 1) == k ){ marc[k] = 1; resp++; }
}
return resp;
}
# | 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... |