Submission #417171

#TimeUsernameProblemLanguageResultExecution timeMemory
417171AmineTrabelsiSeats (IOI18_seats)C++14
0 / 100
414 ms23728 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; vector<int> r,c; int h,w,n; int get(){ int a = r[0],b=c[0],x= r[0],y=c[0]; int ans = 1; for(int i=1;i<n;i++){ int le = r[i], ri = c[i]; if(le < a)a = le; else if(le > x)x = le; if(ri < b)b = ri; else if(ri > y)y = ri; ans += (x-a+1) * (y-b+1) == i+1; i = max(i,(x-a+1) * (y-b+1)-3); } return ans; } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { h = H,w= W,n = H*W; r = R; c = C; } int swap_seats(int a, int b) { swap(r[a],r[b]); swap(c[a],c[b]); return get(); }
#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...