제출 #115366

#제출 시각아이디문제언어결과실행 시간메모리
115366dsjong자리 배치 (IOI18_seats)C++14
17 / 100
4066 ms55588 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; int M,N; int r[1000005],c[1000005]; int last=0; int maxr[1000005],maxc[1000005],minr[1000005],minc[1000005]; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { M=H,N=W; for(int i=0;i<M*N;i++){ r[i]=R[i]; c[i]=C[i]; } for(int i=0;i<M*N;i++){ if(i==0){ maxr[0]=minr[0]=r[i]; maxc[0]=minc[0]=c[i]; } else{ maxr[i]=max(maxr[i-1],r[i]); maxc[i]=max(maxc[i-1],c[i]); minr[i]=min(minr[i-1],r[i]); minc[i]=min(minc[i-1],c[i]); } if((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i+1) last++; } } int swap_seats(int a, int b){ if(a>b) swap(a,b); for(int i=a;i<=b;i++){ if((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i+1) last--; } swap(r[a],r[b]); swap(c[a],c[b]); for(int i=a;i<=b;i++){ if(i==0){ maxr[0]=minr[0]=r[i]; maxc[0]=minc[0]=c[i]; } else{ maxr[i]=max(maxr[i-1],r[i]); maxc[i]=max(maxc[i-1],c[i]); minr[i]=min(minr[i-1],r[i]); minc[i]=min(minc[i-1],c[i]); } if((maxr[i]-minr[i]+1)*(maxc[i]-minc[i]+1)==i+1) last++; } return last; }
#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...