제출 #75664

#제출 시각아이디문제언어결과실행 시간메모리
75664Osama_Alkhodairy자리 배치 (IOI18_seats)C++17
5 / 100
4045 ms212128 KiB
#include <bits/stdc++.h> #include "seats.h" using namespace std; const int N = 1000001; int h, w, n; vector <int> r, c; set <int> rs[N], cs[N]; void give_initial_chart(int H, int W, vector <int> R, vector <int> C) { h = H; w = W; r = R; c = C; n = h * w; for(int i = 0 ; i < H * W ; i++){ rs[r[i]].insert(i); cs[c[i]].insert(i); } } int swap_seats(int a, int b) { int ret = 0; rs[r[a]].erase(a); cs[c[a]].erase(a); rs[r[b]].erase(b); cs[c[b]].erase(b); swap(r[a], r[b]); swap(c[a], c[b]); rs[r[a]].insert(a); cs[c[a]].insert(a); rs[r[b]].insert(b); cs[c[b]].insert(b); set <int> ready; for(int i = 0 ; i < h ; i++){ int cur = *rs[i].begin(); if(cur > 0) ready.insert(cur - 1); ready.insert(cur); } for(int i = 0 ; i < w ; i++){ int cur = *cs[i].begin(); if(cur > 0) ready.insert(cur - 1); ready.insert(cur); } ready.insert(n - 1); int mnr = 1e9, mxr = -1, mnc = 1e9, mxc = -1; for(auto &i : ready){ mnr = min(mnr, r[i]); mnc = min(mnc, c[i]); mxr = max(mxr, r[i]); mxc = max(mxc, c[i]); if((mxr - mnr + 1) * (mxc - mnc + 1) == i + 1) ret++; } return ret; }
#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...