Submission #1223107

#TimeUsernameProblemLanguageResultExecution timeMemory
1223107madamadam3Seats (IOI18_seats)C++20
0 / 100
1583 ms27700 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; // struct Fenw { // int w, h; // vector<vi> bit; // Fenw(int W, int H) { // } // }; int h, w; vi rows, cols; vi prev_ans; int prevv = 0; void give_initial_chart(int H, int W, vi R, vi C) { h = H; w = W; rows = R; cols = C; prev_ans.assign(h*w, 0); prev_ans[0] = 1; int r1 = rows[0], r2 = rows[0]; int c1 = cols[0], c2 = cols[0]; int beautiful = 1; for (int i = 1; i < h*w; i++) { r1 = min(r1, rows[i]); r2 = max(r2, rows[i]); c1 = min(c1, cols[i]); c2 = max(c2, cols[i]); int tl_area = (r2 - r1 + 1) * (c2 - c1 + 1); if (tl_area == i+1) { prev_ans[i] = 1; beautiful++; } } prevv = beautiful; } int swap_seats(int a, int b) { swap(rows[a], rows[b]); swap(cols[a], cols[b]); int r1 = rows[0], r2 = rows[0]; int c1 = cols[0], c2 = cols[0]; int beautiful = prevv; for (int i = a == 0 ? 1 : a; i <= b; i++) { if (prev_ans[i] == 1) { beautiful--; prev_ans[i] = 0; } r1 = min(r1, rows[i]); r2 = max(r2, rows[i]); c1 = min(c1, cols[i]); c2 = max(c2, cols[i]); int tl_area = (r2 - r1 + 1) * (c2 - c1 + 1); if (tl_area == i+1) { beautiful++; prev_ans[i] = 1; } } prevv = beautiful; return beautiful; }
#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...