이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
int r[1010101],c[1010101];
int mr[1010101][2],mc[1010101][2];
int n,m;
int ans=0;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
n=H,m=W;
for(int i=0;i<n*m;i++){
r[i]=R[i];
c[i]=C[i];
mr[i][0]=mr[i][1]=R[i];
mc[i][0]=mc[i][1]=C[i];
}
for(int i=1;i<n*m;i++){
mr[i][0]=min(mr[i][0],mr[i-1][0]);
mr[i][1]=max(mr[i][1],mr[i-1][1]);
mc[i][0]=min(mc[i][0],mc[i-1][0]);
mc[i][1]=max(mc[i][1],mc[i-1][1]);
}
for(int i=0;i<n*m;i++){
//cout<<i<<" "<<r[i]<<" "<<c[i]<<" "<<mr[i][1]<<" "<<mr[i][0]<<" "<<mc[i][1]<<" "<<mc[i][0]<<" "<<(mr[i][1]-mr[i][0]+1)*(mc[i][1]-mc[i][0]+1)<<endl;
if((mr[i][1]-mr[i][0]+1)*(mc[i][1]-mc[i][0]+1)==i+1) ans++;
}
}
int swap_seats(int a, int b) {
if(a>b) swap(a,b);
swap(r[a],r[b]);
swap(c[a],c[b]);
//cout<<a<<" "<<b<<endl;
for(int i=a;i<b;i++){
//cout<<i<<" "<<r[i]<<" "<<c[i]<<" "<<mr[i][1]<<" "<<mr[i][0]<<" "<<mc[i][1]<<" "<<mc[i][0]<<" "<<(mr[i][1]-mr[i][0]+1)*(mc[i][1]-mc[i][0]+1)<<endl;
if((mr[i][1]-mr[i][0]+1)*(mc[i][1]-mc[i][0]+1)==i+1) ans--;
if(i){
mr[i][0]=min(r[i],mr[i-1][0]);
mr[i][1]=max(r[i],mr[i-1][1]);
mc[i][0]=min(c[i],mc[i-1][0]);
mc[i][1]=max(c[i],mc[i-1][1]);
}
else{
mr[i][0]=mr[i][1]=r[i];
mc[i][0]=mc[i][1]=c[i];
}
//cout<<i<<" "<<r[i]<<" "<<c[i]<<" "<<mr[i][1]<<" "<<mr[i][0]<<" "<<mc[i][1]<<" "<<mc[i][0]<<" "<<(mr[i][1]-mr[i][0]+1)*(mc[i][1]-mc[i][0]+1)<<endl;
if((mr[i][1]-mr[i][0]+1)*(mc[i][1]-mc[i][0]+1)==i+1) ans++;
}
return ans;
}
# | 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... |