이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include<bits/stdc++.h>
using namespace std;
int maxr[2000000] ,maxc[2000000] , minr[2000000] , minc[2000000] , vis[2000000];
int erg = 0;
pair<int , int>pl[2000000];
void up(int i , int r , int c){
if(i != 0){
maxr[i] = maxr[i - 1];
maxc[i] = maxc[i - 1];
minr[i] = minr[i - 1];
minc[i] = minc[i - 1];
}
else{
maxr[i] = r;
maxc[i] = c;
minr[i] = r;
minc[i] = c;
}
maxr[i] = max(maxr[i] , r);
maxc[i] = max(maxc[i] , c);
minr[i] = min(minr[i] , r);
minc[i] = min(minc[i] , c);
}
void give_initial_chart(int H, int W, vector<int> r, vector<int> c) {
int menge = H * W;
for(int i = 0 ; i < menge ; i++){
pl[i] = {r[i] , c[i]};
up(i , pl[i].first , pl[i].second);
if(i + 1 == (maxr[i] - minr[i] + 1) * (maxc[i] - minc[i] + 1)){
vis[i] = 1;
erg++;
}
}
// cout << erg << "\n";
}
int swap_seats(int a, int b) {
if(a > b){
swap(a , b);
}
swap(pl[a] , pl[b]);
for(int i = a ; i < b ; i++){
up(i , pl[i].first , pl[i].second);
// cout << maxr[i] << ' ' << minr[i] <<' ' << maxc[i] << ' ' << minc[i] << "\n";
if(i + 1 == (maxr[i] - minr[i] + 1) * (maxc[i] - minc[i] + 1)){
if(vis[i] == 0){
vis[i] = 1;
erg++;
}
}
else{
if(vis[i] == 1){
vis[i] = 0;
erg--;
}
}
}
return erg;
}
# | 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... |