Submission #333599

#TimeUsernameProblemLanguageResultExecution timeMemory
333599nicholaskSeats (IOI18_seats)C++14
Compilation error
0 ms0 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; int n,m; pair <int,int> pos[1000000]; vector <vector <int> > a; void give_initial_chart(int h,int w,vector <int> r,vector <int> c){ n=h; m=w; vector <vector <int> > v(h); for (int i=0; i<h; i++){ vector <int> e(w); v[i]=e; } for (int i=0; i<h*w; i++){ pos[i]={r[i],c[i]}; v[r[i]][c[i]]=i; } a=v; } int swap_seats(int a,int b){ pair <int,int> wha=pos[a],whb=pos[b]; swap(pos[a],pos[b]); swap(a[wha.first][wha.second],a[whb.first][whb.second]); int ans=0; int minr=1e9,maxr=-1e9,minc=1e9,maxc=-1e9; for (int i=0; i<m*n; i++){ //get pos[i] minr=min(minr,pos[i].first); maxr=max(maxr,pos[i].first); minc=min(minc,pos[i].second); maxc=max(maxc,pos[i].second); int a=(maxr-minr+1)*(maxc-minc+1); if (a==i+1) ans++; } return ans; }

Compilation message (stderr)

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:24:18: error: invalid types 'int[int]' for array subscript
   24 |  swap(a[wha.first][wha.second],a[whb.first][whb.second]);
      |                  ^
seats.cpp:24:43: error: invalid types 'int[int]' for array subscript
   24 |  swap(a[wha.first][wha.second],a[whb.first][whb.second]);
      |                                           ^