Submission #1020116

#TimeUsernameProblemLanguageResultExecution timeMemory
1020116mansurSeats (IOI18_seats)C++17
17 / 100
4043 ms60364 KiB
#include "seats.h" #include<bits/stdc++.h> using namespace std; #define rall(s) s.rbegin(), s.rend() #define all(s) s.begin(), s.end() #define sz(s) (int)s.size() #define s second #define f first using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 1e6 + 5; int h, w, k, is[N]; int v[N][4], ans; vector<int> r, c; void f(int p) { ans -= is[p]; v[p][0] = min(v[p - 1][0], r[p]); v[p][1] = min(v[p - 1][1], c[p]); v[p][2] = max(v[p - 1][2], r[p]); v[p][3] = max(v[p - 1][3], c[p]); is[p] = ((v[p][2] - v[p][0] + 1) * (v[p][3] - v[p][1] + 1) == p); ans += is[p]; } void give_initial_chart(int h1, int w1, vector<int> r1, vector<int> c1) { h = h1, w = w1; r = r1, c = c1; reverse(all(r)), reverse(all(c)); r.push_back(0), c.push_back(0); reverse(all(r)), reverse(all(c)); k = h * w; v[0][0] = N, v[0][1] = N; v[0][2] = 0, v[0][3] = 0; for (int i = 1; i <= k; i++) f(i); } int swap_seats(int a, int b) { a++, b++; if (a > b) swap(a, b); swap(r[a], r[b]); swap(c[a], c[b]); for (int i = a; i <= b; i++) f(i); return ans; }
#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...