Submission #1009748

#TimeUsernameProblemLanguageResultExecution timeMemory
1009748HappyCapybaraSeats (IOI18_seats)C++17
11 / 100
4051 ms67000 KiB
#include "seats.h" #include<bits/stdc++.h> using namespace std; int h, w; vector<int> r, c; void give_initial_chart(int H, int W, vector<int> R, vector<int> C){ h = H; w = W; r = R; c = C; } int swap_seats(int a, int b){ swap(r[a], r[b]); swap(c[a], c[b]); int res = 1; int T = r[0], B = r[0], L = c[0], R = c[0]; unordered_set<int> s; for (int i=1; i<h*w; i++){ int next = w*r[i] + c[i]; if (r[i] < T){ for (int j=r[i]; j<T; j++){ for (int k=min(L, c[i]); k<=max(R, c[i]); k++) s.insert(w*j + k); } } if (r[i] > B){ for (int j=B+1; j<=r[i]; j++){ for (int k=min(L, c[i]); k<=max(R, c[i]); k++) s.insert(w*j + k); } } if (c[i] < L){ for (int j=T; j<=B; j++){ for (int k=c[i]; k<L; k++) s.insert(w*j + k); } } if (c[i] > R){ for (int j=T; j<=B; j++){ for (int k=R+1; k<=c[i]; k++) s.insert(w*j + k); } } T = min(T, r[i]); B = max(B, r[i]); L = min(L, c[i]); R = max(R, c[i]); s.erase(next); if (s.empty()) res++; } 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...