Submission #366615

#TimeUsernameProblemLanguageResultExecution timeMemory
366615denkendoemeerSeats (IOI18_seats)C++14
17 / 100
4088 ms57176 KiB
#include "seats.h" #include<bits/stdc++.h> using namespace std; int h,w,ans; vector<pair<int,int>>v; vector<int>xmin,xmax,ymin,ymax; void give_initial_chart(int h2,int w2,vector<int>r,vector<int>c) { h=h2; w=w2; xmin=ymin=xmax=ymax=vector<int>(h*w); int i; for(i=0;i<h*w;i++) v.push_back({r[i],c[i]}); xmin[0]=xmax[0]=v[0].first; ymin[0]=ymax[0]=v[0].second; for(i=1;i<h*w;i++){ xmin[i]=min(xmin[i-1],v[i].first); xmax[i]=max(xmax[i-1],v[i].first); ymin[i]=min(ymin[i-1],v[i].second); ymax[i]=max(ymax[i-1],v[i].second); } for(i=0;i<h*w;i++){ if (i+1==(xmax[i]-xmin[i]+1)*(ymax[i]-ymin[i]+1)) ans++; } } int swap_seats(int a,int b) { if (a>b) swap(a,b); swap(v[a],v[b]); if (a==0){ xmin[0]=xmax[0]=v[0].first; ymin[0]=ymax[0]=v[0].second; } int i; for(i=max(a,1);i<=b;i++){ if (i+1==(xmax[i]-xmin[i]+1)*(ymax[i]-ymin[i]+1)) ans--; xmin[i]=min(xmin[i-1],v[i].first); xmax[i]=max(xmax[i-1],v[i].first); ymin[i]=min(ymin[i-1],v[i].second); ymax[i]=max(ymax[i-1],v[i].second); if (i+1==(xmax[i]-xmin[i]+1)*(ymax[i]-ymin[i]+1)) ans++; } return ans; }
#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...