이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll>> g;int h,w;int n;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
h=H;w=W;n=h*w;for(int i=0;i<n;i++){g.push_back({R[i],C[i]});}
}
int swap_seats(int a, int b) {
swap(g[a],g[b]);
pair<ll,ll> mi,mx;mi={1000001,1000001};mx={-1000001,-1000001};
//pair<ll,ll> lm={1000001,1000001},um={1000001,1000001},rm={-1000001,-1000001},dm={-1000001,-1000001};
int lm=1000001,um=1000001,rm=-1000001,dm=-1000001;
long long t=0;
for(int i=0;i<=n;i++){
mi=min(mi,g[i]);mx=max(mx,g[i]);
/*if(g[i].second<lm.second)lm=g[i];
if(g[i].second>rm.second)rm=g[i];
if(g[i].first<um.first)um=g[i];
if(g[i].first>dm.first)dm=g[i];*/
if(g[i].second<lm)lm=g[i].second;
if(g[i].second>rm)rm=g[i].second;
if(g[i].first<um)um=g[i].first;
if(g[i].first>dm)dm=g[i].first;
//cerr<<mi.first<<' '<<mi.second<<" | "<<mx.first<<' '<<mx.second;
if((mx.first-mi.first+1)*(mx.second-mi.second+1)==i+1&&rm-lm==mx.second-mi.second&&dm-um==mx.first-mi.first){t++;}//cerr<<" ***";}cerr<<endl;
//cerr<<lm<<'-'<<um<<'-'<<rm<<'-'<<dm<<endl;
//cerr<<(lm-rm)<<' '<<mx.second-mi.second<<endl;
//cerr<<(lm-rm==mx.second-mi.second)<<' '<<(dm-um==mx.first-mi.first)<<endl;
}
return t;
}
/*
2 3 2
0 0
1 0
1 1
0 1
0 2
1 2
0 5
0 5
*/
# | 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... |