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>
#include "seats.h"
#define debug
#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
const int MAXN = 1e4+10 ;
const int inf=1e9+10 ;
using namespace std ;
int n ;
pii p[MAXN] ;
// ------------------------------------
int swap_seats(int a , int b)
{
pii p1 = mk( inf , inf ) , p2 = mk(-1,-1) ;
int cnt = 0 ;
swap( p[a] , p[b] ) ;
lp(i,0,n)
{
pii cur = p[i] ;
p1.ff=min(p1.ff, cur.ff) ;
p1.ss = min(p1.ss , cur.ss) ;
p2.ff = max(p2.ff , cur.ff) ;
p2.ss = max(p2.ss , cur.ss) ;
int grid = ( p2.ff - p1.ff + 1) * ( p2.ss - p1.ss + 1) ;
if( i+1 == grid ) cnt ++ ;
}
return cnt ;
}
void give_initial_chart(int h , int w , vector<int> R , vector<int> C )
{
n = R.size() ;
lp(i,0,n) p[i] = mk( R[i] , C[i] ) ;
}
# | 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... |