이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int,int>> v;
vector<int> a, b, c, d;
vector<bool> lehet;
int ans;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
n = H*W;
v.resize(n);
a.resize(n); b.resize(n);
c.resize(n); d.resize(n);
lehet.resize(n);
for(int i = 0; i < n; i++){
v[i] = {R[i], C[i]};
}
int ca = v[0].first, cb = v[0].first, cc = v[0].second, cd = v[0].second;
a[0] = ca, b[0] = cb, c[0] = cc, d[0] = cd;
lehet[0] = 1;
ans = 1;
for(int i = 1; i < n; i++){
ca = min(ca, v[i].first);
cb = max(cb, v[i].first);
cc = min(cc, v[i].second);
cd = max(cd, v[i].second);
if(i+1 == (cb-ca+1)*(cd-cc+1)){
lehet[i] = true;
ans++;
}
a[i] = ca, b[i] = cb, c[i] = cc, d[i] = cd;
}
}
int swap_seats(int x, int y) {
swap(v[x], v[y]);
if(x > y)swap(x, y);
int ca, cb, cc, cd;
if(x == 0){
ca = v[0].first; cb = v[0].first;
cc = v[0].second; cd = v[0].second;
} else {
ca = a[x-1]; cb = b[x-1];
cc = c[x-1]; cd = d[x-1];
}
for(int i = x; i <= y; i++){
ca = min(ca, v[i].first);
cb = max(cb, v[i].first);
cc = min(cc, v[i].second);
cd = max(cd, v[i].second);
if(i+1 == (cb-ca+1)*(cd-cc+1)){
if(!lehet[i]){
lehet[i] = true;
ans++;
}
} else {
if(lehet[i]){
lehet[i] = false;
ans--;
}
}
a[i] = ca, b[i] = cb, c[i] = cc, d[i] = cd;
}
return ans;
}
# | 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... |