이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
int h, w;
vector<int> r, c;
void maxi(int& a, int b){
a = max(a, b);
}
void mini(int& a, int b){
a = min(a, b);
}
int getans(){
int rmax = r[0];
int rmin = r[0];
int cmax = c[0];
int cmin = c[0];
//cout << rmax << " " << rmin << " - " << cmax << " " << cmin << endl;
int ans = 1;
for (int i = 1; i < h*w; i++){
maxi(rmax, r[i]);
mini(rmin, r[i]);
maxi(cmax, c[i]);
mini(cmin, c[i]);
//cout << rmax << " " << rmin << " - " << cmax << " " << cmin << endl;
if ((rmax-rmin+1)*(cmax-cmin+1) == i+1) ans++;
}
return ans;
}
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
h = H;
w = W;
for (int i = 0; i < h*w; i++){
r.push_back(R[i]);
c.push_back(C[i]);
}
}
int swap_seats(int a, int b) {
int tmp = r[a];
r[a] = r[b];
r[b] = tmp;
tmp = c[a];
c[a] = c[b];
c[b] = tmp;
return getans();
}
# | 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... |