제출 #1009745

#제출 시각아이디문제언어결과실행 시간메모리
1009745HappyCapybara자리 배치 (IOI18_seats)C++17
0 / 100
4096 ms74476 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 = h*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(h*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(h*j + k); } } if (c[i] < L){ for (int j=T; j<=B; j++){ for (int k=c[i]; k<L; k++) s.insert(h*j + k); } } if (c[i] > R){ for (int j=T; j<=B; j++){ for (int k=R+1; k<=c[i]; k++) s.insert(h*j + k); } } T = min(T, r[i]); B = max(T, 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...