Submission #333598

#TimeUsernameProblemLanguageResultExecution timeMemory
333598nicholaskSeats (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(v[wha.first][wha.second],v[whb.first][whb.second]);
	int ans=0;
	int minr=1e9,maxr=-1e9,minc=1e9,maxc=-1e9;
	for (int i=0; i<h*w; 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:7: error: 'v' was not declared in this scope
   24 |  swap(v[wha.first][wha.second],v[whb.first][whb.second]);
      |       ^
seats.cpp:27:18: error: 'h' was not declared in this scope
   27 |  for (int i=0; i<h*w; i++){
      |                  ^
seats.cpp:27:20: error: 'w' was not declared in this scope
   27 |  for (int i=0; i<h*w; i++){
      |                    ^