QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#713258#8236. Snake Movenodnodnod123Compile Error//C++141.5kb2024-11-05 18:47:552024-11-05 18:47:56

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 18:47:56]
  • 评测
  • [2024-11-05 18:47:55]
  • 提交

answer

#include<iostream>
#include<utility>
#include<vector>
#include<queue>
using namespace std;

int n, m, k;
char map[3005][3005];
int vis[3005][3005];
long long dis[9000005];
int gox[4] = { -1,0,1,0 };
int goy[4] = { 0,1,0,-1 };
long long flag[3005][3005];
vector<pair<long long, long long> > body;
struct dian{
	long long x, y, di;
};
priority_queue<dian> q;

void dij() {
	while (!q.empty()) {
		dian t = q.top();
		q.pop();
		long long x1 =t.x, y1 = t.y;
		long long d = t.di;
		if (vis[x1][y1] == 1) continue;
		for (int i = 0; i < 4; i++) {
			int xx = x1 + gox[i], yy = y1 + goy[i];
			if (vis[xx][yy] == 1 || map[xx][yy] == '#' || xx > n || xx<1 || yy>m || yy < 1) continue;
			if (max(d + 1, flag[xx][yy] + 1) < dis[(xx - 1) * m + yy]) {
				dis[(xx - 1) * m + yy] = max(d + 1, flag[xx][yy] + 1);
				q.push({xx,yy,dis[(xx - 1) * m + yy]});
			}
		}
		vis[x1][y1] = 1;
	}
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m >> k;
	int u, v;
	int x0, y0;
	for (int i = 1; i <= k; i++) {
		cin >> u >> v;
		flag[u][v] = k - i;
		if (i == 1) {
			x0 = u;
			y0 = v;
			dis[(x0 - 1) * m + y0] = 0;
			q.push({x0,y0,0});
		}
	}
	for (int i = 1; i <= n * m; i++) {
		dis[i] = 1e9 + 5;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> map[i][j];
		}
	}
	dij();
	unsigned long long ans = 0;
	for (int i = 1; i <= m * n; i++) {
		if (dis[i] == 1e9 + 5) continue;
		ans = ans + (dis[i] * dis[i]);
	}
	cout << ans << endl;
	return 0;
}

详细

In file included from /usr/include/c++/13/string:49,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_function.h: In instantiation of ‘constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = dian]’:
/usr/include/c++/13/bits/predefined_ops.h:196:23:   required from ‘bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<dian*, std::vector<dian, std::allocator<dian> > >; _Value = dian; _Compare = std::less<dian>]’
/usr/include/c++/13/bits/stl_heap.h:140:48:   required from ‘void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<dian*, vector<dian, allocator<dian> > >; _Distance = long int; _Tp = dian; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<dian> >]’
/usr/include/c++/13/bits/stl_heap.h:216:23:   required from ‘void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<dian*, vector<dian, allocator<dian> > >; _Compare = less<dian>]’
/usr/include/c++/13/bits/stl_queue.h:749:16:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = dian; _Sequence = std::vector<dian, std::allocator<dian> >; _Compare = std::less<dian>; value_type = dian]’
answer.code:32:11:   required from here
/usr/include/c++/13/bits/stl_function.h:408:20: error: no match for ‘operator<’ (operand types are ‘const dian’ and ‘const dian’)
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/13/string:48:
/usr/include/c++/13/bits/stl_iterator.h:455:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’
  455 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const dian’ is not derived from ‘const std::reverse_iterator<_Iterator>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:500:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  500 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const dian’ is not derived from ‘const std::reverse_iterator<_Iterator>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:1705:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1705 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1705:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const dian’ is not derived from ‘const std::move_iterator<_IteratorL>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:1770:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’
 1770 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1770:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const dian’ is not derived from ‘const std::move_iterator<_IteratorL>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~