제출 #1330715

#제출 시각아이디문제언어결과실행 시간메모리
1330715MuhammadSaram자리 배치 (IOI18_seats)C++20
컴파일 에러
0 ms0 KiB
#include "seats.h"
#include <bits/stdc++.h>

using namespace std;

const int M = 1e6 + 1;

vector<int> r[2];
int mn[M][2], mx[M][2], val[M], ans;

void ver(int x)
{
	ans-=val[x], val[x]=0;
	if ((mx[x][0]-mn[x][0]+1)*(mx[x][1]-mn[x][1]+1)==x+1) val[x]=1;
	ans+=val[x];
}

void give_initial_chart(int h, int w, vector<int> R, vector<int> C)
{
	r[0] = R, r[1]=C;
	mn[0][0]=mx[0][0]=r[0], mn[0][1]=mx[0][1]=c[0];
	ver(1);
	for (int i=1;i<h*w;i++)
	{
		for (int j=0;j<=1;j++)
			mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
		if (ver(i))
			val[i]=1, ans++;
	}
}

int swap_seats(int a, int b)
{
	swap(r[a][0],r[b][0]), swap(r[a][1],r[b][1]);
	if (!a)
	{
		for (int j=0;j<=1;j++) mn[0][j]=mx[0][j]=r[0][j];
	}
	else
	{
		for (int j=0;j<=1;j++)
			mn[a][j]=min(mn[a-1][j],r[a][j]), mx[a][j]=max(mx[a-1][j],r[a][j]);
	}
	ver(a);
	for (int i=a+1;i<=b;i++)
		mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]), ver(i);
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:21:30: error: cannot convert 'std::vector<int>' to 'int' in assignment
   21 |         mn[0][0]=mx[0][0]=r[0], mn[0][1]=mx[0][1]=c[0];
      |                           ~~~^
      |                              |
      |                              std::vector<int>
seats.cpp:21:51: error: 'c' was not declared in this scope
   21 |         mn[0][0]=mx[0][0]=r[0], mn[0][1]=mx[0][1]=c[0];
      |                                                   ^
seats.cpp:26:37: error: no matching function for call to 'min(int&, std::vector<int>&)'
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                  ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
seats.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>')
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                  ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
seats.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>')
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                  ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from seats.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
seats.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                  ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
seats.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                  ~~~^~~~~~~~~~~~~~~~~
seats.cpp:26:68: error: no matching function for call to 'max(int&, std::vector<int>&)'
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
seats.cpp:26:68: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>')
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
seats.cpp:26:68: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>')
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
seats.cpp:26:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
seats.cpp:26:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                         mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~
seats.cpp:27:24: error: could not convert 'ver(i)' from 'void' to 'bool'
   27 |                 if (ver(i))
      |                     ~~~^~~
      |                        |
      |                        void
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:46:23: error: 'j' was not declared in this scope
   46 |                 mn[i][j]=min(mn[i-1][j],r[j]), mx[i][j]=max(mx[i-1][j],r[j]), ver(i);
      |                       ^