제출 #209667

#제출 시각아이디문제언어결과실행 시간메모리
209667TAISA_자리 배치 (IOI18_seats)C++14
11 / 100
4097 ms39928 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; void chmin(int& a,int b){a=min(a,b);} void chmax(int& a,int b){a=max(a,b);} vector<int> r,c,xmi,xma,ymi,yma; int h,w,cnt; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { r=R; c=C; h=H; w=W; xmi.resize(H*W); xma.resize(H*W); ymi.resize(H*W); yma.resize(H*W); xmi[0]=c[0],xma[0]=c[0],ymi[0]=r[0],yma[0]=r[0]; cnt=1; for(int i=1;i<h*w;i++){ xmi[i]=xmi[i-1],ymi[i]=ymi[i-1],xma[i]=xma[i-1],yma[i]=yma[i-1]; chmin(xmi[i],c[i]); chmin(ymi[i],r[i]); chmax(xma[i],c[i]); chmax(yma[i],r[i]); if((xma[i]-xmi[i]+1)*(yma[i]-ymi[i]+1)==i+1){ cnt++; } } } int swap_seats(int a, int b) { /*for(int i=a;i<=b;i++){ if((xma[i]-xmi[i]+1)*(yma[i]-ymi[i]+1)==i+1){ cnt--; } }*/ cnt=0; swap(r[a],r[b]); swap(c[a],c[b]); for(int i=0;i<h*w;i++){ if(i>0){ xmi[i]=xmi[i-1],ymi[i]=ymi[i-1],xma[i]=xma[i-1],yma[i]=yma[i-1]; }else{ xmi[0]=c[0],xma[0]=c[0],ymi[0]=r[0],yma[0]=r[0]; } chmin(xmi[i],c[i]); chmin(ymi[i],r[i]); chmax(xma[i],c[i]); chmax(yma[i],r[i]); if((xma[i]-xmi[i]+1)*(yma[i]-ymi[i]+1)==i+1){ cnt++; } } return cnt; }
#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...