Submission #769174

#TimeUsernameProblemLanguageResultExecution timeMemory
769174pashkaSeats (IOI18_seats)C++14
0 / 100
196 ms62340 KiB
#include "seats.h" using namespace std; int n, m; vector<int> x; vector<int> y; int res; vector<int> minx, maxx, miny, maxy; vector<bool> pr; void recalc() { minx[0] = n - 1; maxx[0] = 0; miny[0] = m - 1; maxy[0] = 0; for (int i = 0; i < n * m; i++) { minx[i + 1] = min(minx[i], x[i]); maxx[i + 1] = max(maxx[i], x[i]); miny[i + 1] = min(miny[i], y[i]); maxy[i + 1] = max(maxy[i], y[i]); } for (int i = 1; i <= n * m; i++) { pr[i] = ((maxx[i] - minx[i] + 1) * (maxy[i] - miny[i] + 1) == i); } res = 0; for (int i = 0; i < n * m; i++) { res += pr[i + 1]; } } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { x = R; y = C; n = H; m = W; recalc(); } int swap_seats(int a, int b) { swap(x[a], x[b]); swap(y[a], y[b]); recalc(); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...