# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111548 | SalihSahin | Seats (IOI18_seats) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#include "seats.h"
using namespace std;
vector<pair<int, int> > pos;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C){
pos.resize(H * W);
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
pos[R[i * W + j] * W + C[i * W + j]] = {i, j};
}
}
}
int swap_seats(int a, int b) {
swap(pos[a], pos[b]);
int mnx = h + w, mxx = 0, mny = h + w, mxy = 0;
int ans = 0;
for(int i = 0; i < pos.size(); i++){
mnx = min(mnx, pos[i].second);
mxx = max(mxx, pos[i].second);
mny = min(mny, pos[i].first);
mxy = max(mxy, pos[i].first);
if((mxx - mnx + 1) * (mxy - mny + 1) == (i + 1)){
ans++;
}
}
return ans;
}