제출 #348000

#제출 시각아이디문제언어결과실행 시간메모리
348000tengiz05Rectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include "rect.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
int n, m;
vector<vector<int>> a;
bool check(int r1, int c1, int r2, int c2){
	for(int i=r1;i<=r2;i++){
		for(int j=c1;j<=c2;j++){
			int t = min(min(a[i][c1-1], a[i][c2+1]), min(a[r1-1][j], a[r2+1][j]));
			if(a[i][j] >= t)return false;
		}
	}return true;
}

void print(int r1, int c1, int r2, int c2){
	for(int i=r1;i<=r2;i++){
		for(int j=c1;j<=c2;j++){
			cout << a[i][j] << ' ';
		}cout << '\n';
	}cout << '\n';
}

long long count_rectangles(vector<vector<int>> a){
	::a = a;
	n = a.size();
	m = a[0].size();
	int ans = 0;
	for(int i=1;i<n-1;i++){
		for(int j=1;j<m-1;j++){
			for(int I=i;I<n-1;I++){
				for(int J=j;J<m-1;J++){
					//~ if(check(i,j,I,J)){
						//~ cout << i << ' ' << j << "; " << I << ' ' << J << '\n';
						//~ print(i,j,I,J);
					//~ }
					ans += check(i,j,I,J);
				}
			}
		}
	}return ans;
}

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

rect.cpp:7:1: error: 'vector' does not name a type
    7 | vector<vector<int>> a;
      | ^~~~~~
rect.cpp: In function 'bool check(int, int, int, int)':
rect.cpp:11:20: error: 'a' was not declared in this scope
   11 |    int t = min(min(a[i][c1-1], a[i][c2+1]), min(a[r1-1][j], a[r2+1][j]));
      |                    ^
rect.cpp:11:16: error: 'min' was not declared in this scope; did you mean 'std::min'?
   11 |    int t = min(min(a[i][c1-1], a[i][c2+1]), min(a[r1-1][j], a[r2+1][j]));
      |                ^~~
      |                std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:5:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
rect.cpp:11:12: error: 'min' was not declared in this scope; did you mean 'std::min'?
   11 |    int t = min(min(a[i][c1-1], a[i][c2+1]), min(a[r1-1][j], a[r2+1][j]));
      |            ^~~
      |            std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from rect.cpp:5:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
rect.cpp: In function 'void print(int, int, int, int)':
rect.cpp:20:4: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |    cout << a[i][j] << ' ';
      |    ^~~~
      |    std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:75,
                 from rect.cpp:5:
/usr/include/c++/9/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
rect.cpp:20:12: error: 'a' was not declared in this scope
   20 |    cout << a[i][j] << ' ';
      |            ^
rect.cpp:21:4: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |   }cout << '\n';
      |    ^~~~
      |    std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:75,
                 from rect.cpp:5:
/usr/include/c++/9/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
rect.cpp:22:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |  }cout << '\n';
      |   ^~~~
      |   std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:75,
                 from rect.cpp:5:
/usr/include/c++/9/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
rect.cpp: At global scope:
rect.cpp:25:28: error: 'long long int count_rectangles' redeclared as different kind of entity
   25 | long long count_rectangles(vector<vector<int>> a){
      |                            ^~~~~~
In file included from rect.cpp:1:
rect.h:7:11: note: previous declaration 'long long int count_rectangles(std::vector<std::vector<int> >)'
    7 | long long count_rectangles(std::vector<std::vector<int> > a);
      |           ^~~~~~~~~~~~~~~~
rect.cpp:25:28: error: 'vector' was not declared in this scope
   25 | long long count_rectangles(vector<vector<int>> a){
      |                            ^~~~~~
rect.cpp:25:28: note: suggested alternatives:
In file included from /usr/include/c++/9/vector:67,
                 from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note:   'std::vector'
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/9/vector:90:13: note:   'std::pmr::vector'
   90 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
rect.cpp:25:35: error: 'vector' was not declared in this scope
   25 | long long count_rectangles(vector<vector<int>> a){
      |                                   ^~~~~~
rect.cpp:25:35: note: suggested alternatives:
In file included from /usr/include/c++/9/vector:67,
                 from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note:   'std::vector'
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from rect.h:5,
                 from rect.cpp:1:
/usr/include/c++/9/vector:90:13: note:   'std::pmr::vector'
   90 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
rect.cpp:25:42: error: expected primary-expression before 'int'
   25 | long long count_rectangles(vector<vector<int>> a){
      |                                          ^~~