Submission #595131

#TimeUsernameProblemLanguageResultExecution timeMemory
595131FatihSolakSeats (IOI18_seats)C++17
17 / 100
4067 ms53544 KiB
#include "seats.h" #include <bits/stdc++.h> #define N 1000005 using namespace std; struct node{ int l1 = 1e9,r1 = 0; int l2 = 1e9,r2 = 0; int size(){ return (r1 - l1 + 1) * (r2 - l2 + 1); } }; node merge(node a,node b){ node ret; ret.l1 = min(a.l1,b.l1); ret.r1 = max(a.r1,b.r1); ret.l2 = min(a.l2,b.l2); ret.r2 = max(a.r2,b.r2); return ret; } node v[N]; int cnt = 0; vector<int> r,c; void give_initial_chart(int h, int w, vector<int> R, vector<int> C) { r = R; c = C; for(int i = 0;i<h*w;i++){ v[i] = {r[i],r[i],c[i],c[i]}; if(i) v[i] = merge(v[i],v[i-1]); if(v[i].size() == i+1) cnt++; } } int swap_seats(int a, int b) { if(a > b)swap(a,b); for(int i = a;i<=b;i++){ if(v[i].size() == i+1) cnt--; } swap(r[a],r[b]); swap(c[a],c[b]); for(int i = a;i<=b;i++){ v[i] = {r[i],r[i],c[i],c[i]}; if(i) v[i] = merge(v[i],v[i-1]); if(v[i].size() == i+1) cnt++; } return cnt; }
#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...