Submission #117992

#TimeUsernameProblemLanguageResultExecution timeMemory
117992Osama_AlkhodairySeats (IOI18_seats)C++17
11 / 100
4102 ms48248 KiB
#include <bits/stdc++.h> #include "seats.h" //#include "grader.cpp" using namespace std; const int N = 1000001; int n, m, mnx[N], mny[N], mxx[N], mxy[N], tree[4 * N]; vector <int> x, y; void update(int l, int r, int node, int ind, int val){ if(r < l || l > ind || r < ind) return; if(l == r){ tree[node] = val; return; } int mid = (l + r) / 2; update(l, mid, 2 * node, ind, val); update(mid + 1, r, 2 * node + 1, ind, val); tree[node] = tree[2 * node] + tree[2 * node + 1]; } bool check(int g){ return (mxx[g] - mnx[g] + 1) * (mxy[g] - mny[g] + 1) == g + 1; } void update(int i){ mnx[i] = i == 0 ? x[i] : min(x[i], mnx[i - 1]); mxx[i] = i == 0 ? x[i] : max(x[i], mxx[i - 1]); mny[i] = i == 0 ? y[i] : min(y[i], mny[i - 1]); mxy[i] = i == 0 ? y[i] : max(y[i], mxy[i - 1]); update(0, n * m - 1, 1, i, check(i)); } void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { n = H; m = W; x = R; y = C; for(int i = 0 ; i < n * m ; i++){ update(i); } } int swap_seats(int a, int b) { if(a > b) swap(a, b); swap(x[a], x[b]); swap(y[a], y[b]); for(int i = a ; i <= b ; i++){ update(i); } return tree[1]; }
#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...