이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e6+5;
vector<int> r, c;
int rmn[MAXN], rmx[MAXN];
int cmn[MAXN], cmx[MAXN];
int resp[MAXN];
int respf;
int n, m;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
n=H; m=W;
r=R; c=C;
int mn=MAXN, mx=-1;
int mn2=MAXN, mx2=-1;
for(int i=0; i<n*m; i++) {
mn=min(mn, r[i]); mx=max(mx, r[i]);
mn2=min(mn2, c[i]); mx2=max(mx2, c[i]);
rmn[i]=mn; rmx[i]=mx;
cmn[i]=mn2; cmx[i]=mx2;
int tam=mx-mn+1; tam*=(mx2-mn2+1);
if(i+1==tam) resp[i]=1, respf++;
}
// printf("%d\n", respf);
}
int swap_seats(int a, int b) {
for(int i=a; i<=b; i++) {
int tam=rmx[i]-rmn[i]+1; tam*=(cmx[i]-cmn[i]+1);
if(i+1==tam) respf--;
}
swap(r[a], r[b]);
swap(c[a], c[b]);
int mn= a==0 ? MAXN : rmn[a-1];
int mx= a==0 ? -1 : rmx[a-1];
int mn2= a==0 ? MAXN : cmn[a-1];
int mx2= a==0 ? -1 : cmx[a-1];
for(int i=a; i<=b; i++) {
mn=min(mn, r[i]); mx=max(mx, r[i]);
mn2=min(mn2, c[i]); mx2=max(mx2, c[i]);
rmn[i]=mn; rmx[i]=mx;
cmn[i]=mn2; cmx[i]=mx2;
int tam=rmx[i]-rmn[i]+1; tam*=(cmx[i]-cmn[i]+1);
// printf("%d >> %d\n", i, tam);
if(i+1==tam) respf++;
}
return respf;
}
# | 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... |