이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "seats.h"
#define tol(bi) (1LL<<((int)(bi)))
struct BIT{
BIT(){}
vector<vector<int>> arr;
void init(int n, int m){
arr.resize(n,vector<int>(m,0));
}
void update(int x, int y, int val){
arr[x][y]=val;
}
int minq(int xl, int xr, int yl, int yr){
int rval = 23232323;
for (int i = xl; i <= xr; i++){
for (int j = yl; j <= yr; j++){
rval=min(rval,arr[i][j]);
}
}
return rval;
}
int maxq(int xl, int xr, int yl, int yr){
int rval = 0;
for (int i = xl; i <= xr; i++){
for (int j = yl; j <= yr; j++){
rval=max(rval,arr[i][j]);
}
}
return rval;
}
};
vector<int> R,C;
BIT fenwik;
int H,W;
void give_initial_chart(int _H, int _W, std::vector<int> _R, std::vector<int> _C) {
R=_R,C=_C;
H=_H,W=_W;
fenwik.init(H,W);
for (int i = 0; i < R.size(); ++i)
{
fenwik.update(R[i],C[i],i);
}
}
int swap_seats(int a, int b) {
swap(R[a],R[b]);
swap(C[a],C[b]);
fenwik.update(R[a],C[a],a);
fenwik.update(R[b],C[b],b);
int crmax = 0;
int ans = 1;
int xl=R[0],xr=R[0];
int yl=C[0],yr=C[0];
while (xl>0 || xr<H-1 || yl>0 || yr<W-1){
int minel = 23232323;
if (xl>0) minel=min(minel,fenwik.minq(0,xl-1,0,W-1));
if (xr+1<H) minel=min(minel,fenwik.minq(xr+1,H-1,0,W-1));
if (yl>0) minel=min(minel,fenwik.minq(xl,xr,0,yl-1));
if (yr+1<W) minel=min(minel,fenwik.minq(xl,xr,yr+1,W-1));
xr=max(xr,R[minel]);
xl=min(xl,R[minel]);
yr=max(yr,C[minel]);
yl=min(yl,C[minel]);
crmax=fenwik.maxq(xl,xr,yl,yr);
if ((xr-xl+1)*(yr-yl+1)==crmax+1) ans++;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int i = 0; i < R.size(); ++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... |