제출 #379313

#제출 시각아이디문제언어결과실행 시간메모리
379313autumn_eel자리 배치 (IOI18_seats)C++14
17 / 100
4094 ms59672 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) { if(a>b)swap(a,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...