Submission #777170

#TimeUsernameProblemLanguageResultExecution timeMemory
777170GusterGoose27Seats (IOI18_seats)C++17
20 / 100
2263 ms133796 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int MAXN = 1e6+5; int h, w, n; pii points[MAXN]; set<int> occ[2][1000]; void make_occ(int i) { occ[0][points[i].first].insert(i); occ[1][points[i].second].insert(i); } void un_make(int i) { occ[0][points[i].first].erase(i); occ[1][points[i].second].erase(i); } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { h = H; w = W; n = h*w; for (int i = 0; i < n; i++) { points[i] = pii(R[i], C[i]); make_occ(i); } } int swap_seats(int a, int b) { un_make(a); un_make(b); swap(points[a], points[b]); make_occ(a); make_occ(b); set<int> relevant; for (int i = 0; i < h; i++) relevant.insert(*occ[0][i].begin()); for (int i = 0; i < w; i++) relevant.insert(*occ[1][i].begin()); int l = h, r = 0, u = w, d = 0; int ans = 1; for (int v: relevant) { ans += ((r-l+1)*(d-u+1) == v); l = min(l, points[v].first); r = max(r, points[v].first); u = min(u, points[v].second); d = max(d, points[v].second); } 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...