# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447679 | MilosMilutinovic | 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>
using namespace std;
typedef long long ll;
typedef long unsigned long ull;
typedef double long ld;
int h, w, r[1000005], c[1000005];
void give_initial_chart(int H, int W, int R[], int C[]) {
h = H; w = W;
for (int i = 0; i < h * w; i++) r[i] = R[i];
for (int i = 0; i < h * w; i++) c[i] = C[i];
}
int swap_seats(int a, int b) {
if (h * w <= 10000) {
int ans = 0;
pair<int, int> mn, mx;
mx = mn = {r[0], c[0]};
for (int i = 0; i < h * w; i++) {
mx.first = max(mx.first, r[i]);
mx.second = max(mx.second, c[i]);
mn.first = min(mn.first, r[i]);
mn.second = min(mn.second, c[i]);
if ((mx.first - mn.first + 1) * (mx.second - mn.second + 1) == i + 1) {
ans++;
}
}
return ans;
}
}
int main() {
ios::sync_with_stdio(!cin.tie(0));
}