답안 #475195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475195 2021-09-21T12:13:00 Z bigo Trampoline (info1cup20_trampoline) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <cmath>
typedef pair<int, int> pii;
using namespace std;
vector<vector<int>>vec;
vector<bool>visit;
void dfs(int v) {
	visit[v] = true;
	for (int i = 0; i < vec[v].size(); i++) {
		if (!visit[vec[v][i]])
			dfs(vec[v][i]);
	}
}
int main() {
	int r, c, n;
	cin >> r >> c >> n;
	set<pii>green;
	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		a--, b--;
		green.insert({ a,b });
	}
	vec.resize(r * c);
	visit.resize(r * c, false);
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (green.find({ i,j }) != green.end()) {
				if(i!=r-1)
					vec[i * c + j].push_back(i * c + j + 1);
				if(j!=c-1)
					vec[i * c + j].push_back((i + 1) * c + j);
			}
			else {
				if(j!=c-1)
					vec[i * c + j].push_back(i * c + j + 1);
			}
		}
	}
	int t;
	cin >> t;
	while (t--) {
		int y1, x1, y2, x2;
		cin >> y1 >> x1 >> y2 >> x2;
		y1--, x1--, y2--, x2--;
		dfs(y1 * c + x1);
		if (visit[y2 * c + x2])
			cout << "YES";
		else
			cout << "NO";
		cout << endl;
		for (int i = 0; i < r * c; i++)
			visit[i] = false;
	}
}

Compilation message

trampoline.cpp:3:9: error: 'pair' does not name a type
    3 | typedef pair<int, int> pii;
      |         ^~~~
trampoline.cpp: In function 'void dfs(int)':
trampoline.cpp:8:2: error: reference to 'visit' is ambiguous
    8 |  visit[v] = true;
      |  ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from trampoline.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
trampoline.cpp:6:13: note:                 'std::vector<bool> visit'
    6 | vector<bool>visit;
      |             ^~~~~
trampoline.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for (int i = 0; i < vec[v].size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~
trampoline.cpp:10:8: error: reference to 'visit' is ambiguous
   10 |   if (!visit[vec[v][i]])
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from trampoline.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
trampoline.cpp:6:13: note:                 'std::vector<bool> visit'
    6 | vector<bool>visit;
      |             ^~~~~
trampoline.cpp: In function 'int main()':
trampoline.cpp:17:6: error: 'pii' was not declared in this scope
   17 |  set<pii>green;
      |      ^~~
trampoline.cpp:17:9: error: template argument 1 is invalid
   17 |  set<pii>green;
      |         ^
trampoline.cpp:17:9: error: template argument 2 is invalid
trampoline.cpp:17:9: error: template argument 3 is invalid
trampoline.cpp:22:9: error: request for member 'insert' in 'green', which is of non-class type 'int'
   22 |   green.insert({ a,b });
      |         ^~~~~~
trampoline.cpp:25:2: error: reference to 'visit' is ambiguous
   25 |  visit.resize(r * c, false);
      |  ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from trampoline.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
trampoline.cpp:6:13: note:                 'std::vector<bool> visit'
    6 | vector<bool>visit;
      |             ^~~~~
trampoline.cpp:28:14: error: request for member 'find' in 'green', which is of non-class type 'int'
   28 |    if (green.find({ i,j }) != green.end()) {
      |              ^~~~
trampoline.cpp:28:37: error: request for member 'end' in 'green', which is of non-class type 'int'
   28 |    if (green.find({ i,j }) != green.end()) {
      |                                     ^~~
trampoline.cpp:47:7: error: reference to 'visit' is ambiguous
   47 |   if (visit[y2 * c + x2])
      |       ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from trampoline.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
trampoline.cpp:6:13: note:                 'std::vector<bool> visit'
    6 | vector<bool>visit;
      |             ^~~~~
trampoline.cpp:53:4: error: reference to 'visit' is ambiguous
   53 |    visit[i] = false;
      |    ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from trampoline.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
trampoline.cpp:6:13: note:                 'std::vector<bool> visit'
    6 | vector<bool>visit;
      |             ^~~~~