제출 #431681

#제출 시각아이디문제언어결과실행 시간메모리
431681MDario자리 배치 (IOI18_seats)C++11
6 / 100
4059 ms59672 KiB
#include "seats.h" #include<bits/stdc++.h> using namespace std; vector<int> r, c, rmi, rma, cmi, cma, v; int s=0, n; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { r=R; rmi=R; rma=R; c=C; cmi=C; cma=C; n=H*W; s=1; v.push_back(1); for(int i=1; i<n; i++){ rmi[i]=min(r[i], rmi[i-1]); rma[i]=max(r[i], rma[i-1]); cmi[i]=min(c[i], cmi[i-1]); cma[i]=max(c[i], cma[i-1]); if((rma[i]-rmi[i]+1)*(cma[i]-cmi[i]+1)==i+1){ s++; v.push_back(1); } else v.push_back(0); } return; } int swap_seats(int a, int b) { if(a>b)swap(a, b); swap(r[a], r[b]); swap(c[b], c[a]); a+=(a==0); for(int i=a; i<b; i++){ s-=v[i]; rmi[i]=min(r[i], rmi[i-1]); rma[i]=max(r[i], rma[i-1]); cmi[i]=min(c[i], cmi[i-1]); cma[i]=max(c[i], cma[i-1]); if((rma[i]-rmi[i]+1)*(cma[i]-cmi[i]+1)==i+1){ s++; v[i]=1; } else v[i]=0; } return s; }
#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...