Submission #379311

#TimeUsernameProblemLanguageResultExecution timeMemory
379311autumn_eelSeats (IOI18_seats)C++14
0 / 100
4065 ms43500 KiB
#include "seats.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; static int h,w; static vector<int>r,c; static vector<int>ok; static vector<int>rmin,rmax,cmin,cmax; static int sum; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { h=H;w=W; r=R;c=C; ok=vector<int>(h*w); rmin=rmax=cmin=cmax=vector<int>(h*w); rep(i,h*w){ rmin[i]=rmax[i]=r[i]; cmin[i]=cmax[i]=c[i]; if(i){ rmin[i]=min(rmin[i-1],rmin[i]); rmax[i]=max(rmax[i-1],rmax[i]); cmin[i]=min(cmin[i-1],cmin[i]); cmax[i]=max(cmax[i-1],cmax[i]); } if((rmax[i]-rmin[i]+1)*(cmax[i]-cmin[i]+1)==i+1){ sum++; ok[i]=1; } } } int swap_seats(int a, int b) { swap(r[a],r[b]); swap(c[a],c[b]); for(int i=a;i<=b;i++){ rmin[i]=rmax[i]=r[i]; cmin[i]=cmax[i]=c[i]; if(i){ rmin[i]=min(rmin[i-1],rmin[i]); rmax[i]=max(rmax[i-1],rmax[i]); cmin[i]=min(cmin[i-1],cmin[i]); cmax[i]=max(cmax[i-1],cmax[i]); } sum-=ok[i]; if((rmax[i]-rmin[i]+1)*(cmax[i]-cmin[i]+1)==i+1){ sum++; ok[i]=1; } else ok[i]=0; } return sum; }
#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...