이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "seats.h"
using namespace std;
#define MAX_N 1000006
#define pii pair<int ,int>
#define mxp first
#define mip second
#define FL p<<1
#define FR p<<1|1
int n;
int h ,w ,ans;
vector <int> cor[2] ,sat;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
n = R.size();
h = H;
w = W;
sat.resize(n);
cor[0] = R;
cor[1] = C;
int mxR = 0 ,miR = H;
int mxC = 0 ,miC = W;
for(int i=0; i<R.size(); i++){
mxR = max(mxR ,R[i]);
miR = min(miR ,R[i]);
mxC = max(mxC ,C[i]);
miC = min(miC ,C[i]);
if((mxR-miR+1)*(mxC-miC+1) == i+1)
sat[i] = 1 ,ans++;
}
}
int swap_seats(int a, int b) {
swap(cor[0][a] ,cor[0][b]);
swap(cor[1][a] ,cor[1][b]);
int mxR = 0 ,miR = h;
int mxC = 0 ,miC = w;
for(int i=0; i<=a; i++){
mxR = max(mxR ,cor[0][i]);
miR = min(miR ,cor[0][i]);
mxC = max(mxC ,cor[1][i]);
miC = min(miC ,cor[1][i]);
}
for(int i=a; i<=b; i++){
mxR = max(mxR ,cor[0][i]);
miR = min(miR ,cor[0][i]);
mxC = max(mxC ,cor[1][i]);
miC = min(miC ,cor[1][i]);
if((mxR-miR+1)*(mxC-miC+1) == i+1){
if(!sat[i]){ sat[i] = 1 ,ans++; }
}else{
if(sat[i]){ sat[i] = 0 ,ans--; }
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:26:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | 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... |