이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>MAT;
pair<int,int>MP[1000001];
int w,h;
int check(int L,int R,int L2,int R2){
int maxer=0;
for(int i=L;i<=R;i++){
for(int l=L2;l<=R2;l++)
maxer=max(maxer,MAT[i][l]);
}
return maxer;
}
int REC(int x1,int x2,int y1,int y2,int MAXER=0){
int MINER=INT_MAX,MINER2=INT_MAX,MINER3=INT_MAX,MINER4=INT_MAX;
int maxer=0;
if(x1)
MINER=check(x1-1,x1-1,y1,y2);
if(x2+1<h)
MINER2=check(x2+1,x2+1,y1,y2);
if(y1)
MINER3=check(x1,x2,y1-1,y1-1);
if(y2+1<w)
MINER4=check(x1,x2,y2+1,y2+1);
int MINER5=min(min(MINER,MINER2),min(MINER3,MINER4));
if(MINER5==INT_MAX)
return 1;
if(MINER5==MINER)
return REC(x1-1,x2,y1,y2,max(MAXER,MINER5))+((x2-x1+1)*(y2-y1+1)==(MAXER+1)?1:0);
else if(MINER5==MINER2)
return REC(x1,x2+1,y1,y2,max(MAXER,MINER5))+((x2-x1+1)*(y2-y1+1)==(MAXER+1)?1:0);
else if(MINER5==MINER3)
return REC(x1,x2,y1-1,y2,max(MAXER,MINER5))+((x2-x1+1)*(y2-y1+1)==(MAXER+1)?1:0);
else if(MINER5==MINER4)
return REC(x1,x2,y1,y2+1,max(MAXER,MINER5))+((x2-x1+1)*(y2-y1+1)==(MAXER+1)?1:0);
}
void give_initial_chart(int H,int W,vector<int>R,vector<int>C){
h=H,w=W;
MAT.resize(H);
for(int i=0;i<H;i++)
MAT[i].resize(W);
for(int i=0;i<H*W;i++)
MAT[R[i]][C[i]]=i,MP[i]={R[i],C[i]};
}
int swap_seats(int a,int b){
swap(MAT[MP[a].first][MP[a].second],MAT[MP[b].first][MP[b].second]);
swap(MP[a],MP[b]);
return REC(MP[0].first,MP[0].first,MP[0].second,MP[0].second);
}
컴파일 시 표준 에러 (stderr) 메시지
seats.cpp: In function 'int REC(int, int, int, int, int)':
seats.cpp:18:5: warning: unused variable 'maxer' [-Wunused-variable]
18 | int maxer=0;
| ^~~~~
seats.cpp:38:1: warning: control reaches end of non-void function [-Wreturn-type]
38 | }
| ^
# | 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... |