이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
std::vector<int> r;
std::vector<int> c;
typedef pair<int,int> ii;
vector<int> vmaxx;
vector<int> vmaxy;
vector<int> vminy;
vector<int> vminx;
int g=0,e,d;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
r = R;
c = C;
int maxx=r[0],minx=r[0],maxy=c[0],miny=c[0];
for(int i=0;i<H*W;i++){
int x1,y1;
x1=r[i];
y1=c[i];
maxx=max(maxx,x1);
minx=min(minx,x1);
maxy=max(maxy,y1);
miny=min(miny,y1);
d=abs(maxx-minx)+1;
e=abs(maxy-miny)+1;
if(d*e==i+1){
g++;
}
vmaxx.pb(maxx);
vmaxy.pb(maxy);
vminx.pb(minx);
vminy.pb(miny);
}
//cout<<g<<endl;
}
int swap_seats(int a, int b) {
int x1,y1;
//int x2,y2;
swap(r[a],r[b]);
swap(c[a],c[b]);
int maxx=r[0],minx=r[0],maxy=c[0],miny=c[0];
/*if(abs(a-b)<=10000){
int j=min(a,b);
int k=max(a,b);
for(int i=j;i<=k;i++){
d=abs(vmaxx[i]-vminx[i])+1;
e=abs(vmaxy[i]-vminy[i])+1;
if(e*d==i+1){
g--;
}
}
int maxx=r[j],minx=r[j],maxy=c[j],miny=c[j];
for(int i=j;i<=k;i++){
x1=r[i];
y1=c[i];
maxx=max(maxx,x1);
minx=min(minx,x1);
maxy=max(maxy,y1);
miny=min(miny,y1);
vmaxx[i]=maxx;
vmaxy[i]=maxy;
vminx[i]=minx;
vminy[i]=miny;
d=abs(vmaxx[i]-vminx[i])+1;
e=abs(vmaxy[i]-vminy[i])+1;
if(e*d==i+1){
g++;
}
}
return g;
}*/
int tam=r.size();
g=0;
for(int i=0;i<tam;i++){
x1=r[i];
y1=c[i];
maxx=max(maxx,x1);
minx=min(minx,x1);
maxy=max(maxy,y1);
miny=min(miny,y1);
d=abs(maxx-minx)+1;
e=abs(maxy-miny)+1;
if(e*d==i+1){
g++;
}
//cout<<d*e<<" "<<g<<endl;
}
return g;
}
# | 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... |