이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
vector<int> r,c;
int h,w;
int cst[1000001];
int mnx[1000001];
int mny[1000001];
int mxx[1000001];
int mxy[1000001];
int all = 0;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C){
h = H;
w = W;
for(int i = 0;i<H*W;i++){
r.push_back(R[i]);
c.push_back(C[i]);
}
mnx[0] = 1e9;
mny[0] = 1e9;
mxx[0] = -1e9;
mxy[0] = -1e9;
for(int i = 0;i<h*w;i++){
mnx[i+1] = min(mnx[i],r[i]);
mxx[i+1] = max(mxx[i],r[i]);
mny[i+1] = min(mny[i],c[i]);
mxy[i+1] = max(mxy[i],c[i]);
if(i+1==(mxx[i+1]-mnx[i+1]+1)*(mxy[i+1]-mny[i+1]+1)){
cst[i] = 1;
all++;
}
}
}
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++){
all-=cst[i];
mnx[i+1] = min(mnx[i],r[i]);
mxx[i+1] = max(mxx[i],r[i]);
mny[i+1] = min(mny[i],c[i]);
mxy[i+1] = max(mxy[i],c[i]);
if(i+1==(mxx[i+1]-mnx[i+1]+1)*(mxy[i+1]-mny[i+1]+1)){
all++;
cst[i] = 1;
}
}
return all;
}
# | 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... |