제출 #431470

#제출 시각아이디문제언어결과실행 시간메모리
431470Bench0310자리 배치 (IOI18_seats)C++17
0 / 100
4041 ms39472 KiB
#include <bits/stdc++.h> #include "seats.h" using namespace std; typedef long long ll; int n,h,w; vector<array<int,2>> v; vector<int> ar,br,ac,bc; int res=0; int ok(int i){return ((br[i]-ar[i]+1)*(bc[i]-ac[i]+1)==i+1);} void give_initial_chart(int nh,int nw,vector<int> r,vector<int> c) { h=nh; w=nw; n=h*w; v.assign(n,{0,0}); for(int i=0;i<n;i++) v[i]={r[i],c[i]}; ar.assign(n,v[0][0]); br.assign(n,v[0][0]); ac.assign(n,v[0][1]); bc.assign(n,v[0][1]); res=ok(0); for(int i=1;i<n;i++) { ar[i]=min(ar[i-1],v[i][0]); br[i]=max(br[i-1],v[i][0]); ac[i]=min(ac[i-1],v[i][1]); bc[i]=max(bc[i-1],v[i][1]); res+=ok(i); } } int swap_seats(int a,int b) { swap(v[a],v[b]); for(int i=a;i<=b;i++) { res-=ok(i); ar[i]=min((i>0?ar[i-1]:n),v[i][0]); br[i]=max((i>0?br[i-1]:0),v[i][0]); ac[i]=min((i>0?ac[i-1]:n),v[i][1]); bc[i]=max((i>0?bc[i-1]:0),v[i][1]); res+=ok(i); } return res; } //int main() //{ // // return 0; //}
#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...