Submission #366612

#TimeUsernameProblemLanguageResultExecution timeMemory
366612denkendoemeerSeats (IOI18_seats)C++14
Compilation error
0 ms0 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; } 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; }

Compilation message (stderr)

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:37:9: error: 'i' was not declared in this scope
   37 |     for(i=max(a,1);i<=b;i++){
      |         ^