이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <utility>
#include <iostream>
using namespace std;
std::vector<int> r;
std::vector<int> c;
std::vector< pair<int,int> > pos;
int K;
// int debug = true; //false;
int debug = false;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
r = R;
c = C;
K = R.size();
for ( int i = 0 ; i < K ; i++) {
// if( debug ) cout << R[i] << C[i] << endl;
pos.push_back(make_pair(R[i],C[i]));
}
debug = true;
}
int r1,r2,c1,c2;
int add_rect( int r, int c)
{
int changed = 0;
if ( r >= r1 && r <= r2 && c >= c1 && c <= c2) changed = 0;
else {
if ( r < r1 ) r1 = r;
else if( r > r2 ) r2 = r;
if ( c < c1 ) c1 = c;
else if( c > c2 ) c2 = c;
changed = 1;
}
return changed ;
}
int swap_seats(int a, int b) {
if( debug ) cout << "Swap : " << a << b << endl;
pair<int,int> t = pos[b];
pos[b]=pos[a];
pos[a]=t;
r1=r2=pos[0].first;
c1=c2=pos[0].second;
int cnt = 0;
if( debug ) cout << 0 << r1 << r2 << c1 << c2 << endl;
for( int i =0 ; i < K ; ) {
int changed = add_rect( pos[i].first , pos[i].second ) ;
if( debug ) { cout << i << changed << r1 << r2 << c1 << c2 << endl; }
if ( (r2-r1+1)*(c2-c1+1) <= i+1 ) {
if( debug ) cout << "BRect " << i+1 << endl;
cnt++;
i++;
} else {
i = (r2-r1+1)*(c2-c1+1)-1;
}
}
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... |