QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#672724#8236. Snake MoveSwd146296#Compile Error//C++201.5kb2024-10-24 18:27:342024-10-24 18:27:34

Judging History

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

  • [2024-10-24 18:27:34]
  • 评测
  • [2024-10-24 18:27:34]
  • 提交

answer

#include<bits/stdc++.h>
#define pii std::pair<int, int>
#define fs first
#define sc second
#define mp std::make_pair

typedef unsigned long long ull;

int n, m, k;
char map[3007][3007];
ull dis[3007][3007];
int vis[3007][3007];
int dx[5] = {0, 0, 1, 0, -1};
int dy[5] = {0, 1, 0, -1, 0};
std::priority_queue<std::pair<int, pii>, std::vector<std::pair<int,pii> >, std::greater<std::pair<int, pii> > >q;

int main()
{
	memset(dis, 0x3f, sizeof dis);
	std::cin >> n >> m >> k;
	for(int i = 1; i <= k; i++)
	{
		int fi, se;
		std::cin >> fi >> se;
		vis[fi][se] = k - i + 1;
		if(i == 1) {
			q.push(mp( 0, mp(fi, se) ));
			dis[fi][se] = 0;
		}
	}
	for(int i = 1; i <= n; i++)
		std::cin >> (map[i] + 1);
	while(q.size())
	{
		std::pair<int,pii> fr = q.top();
		pii pt = fr.sc; 
		q.pop();
		if(dis[pt.fs][pt.sc] != fr.fs)
			continue;
		for(int i = 1; i <= 4; i++)
		{
			int newx = pt.fs + dx[i];
			int newy = pt.sc + dy[i];
			if(newx < 1 || newx > n || newy < 1 || newy > m)
				continue;
			if(map[newx][newy] == '#')
				continue;
			if(dis[newx][newy] > dis[pt.fs][pt.sc] + 1)
			{
				//printf("%d%d %d\n",newx,newy,std::max(dis[pt.fs][pt.sc] + 1, ull(vis[newx][newy])));
				dis[newx][newy] = std::max(dis[pt.fs][pt.sc] + 1, ull(vis[newx][newy]));
				q.push(mp(dis[newx][newy], mp(newx, newy) ));
			}
		}
	}
	ull ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(dis[i][j] != 0x3f3f3f3f3f3f3f3f)
				ans += dis[i][j] * dis[i][j];
		}
	}
	std::cout << ans << std::endl;
}


详细

answer.code: In function ‘int main()’:
answer.code:32:26: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   32 |                 std::cin >> (map[i] + 1);
      |                 ~~~~~~~~ ^~ ~~~~~~~~~~~~
      |                      |              |
      |                      |              char*
      |                      std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:32:37: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   32 |                 std::cin >> (map[i] + 1);
      |                             ~~~~~~~~^~~~
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:32:37: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   32 |                 std::cin >> (map[i] + 1);
      |                             ~~~~~~~~^~~~
      |                                     |
      |                                     char*
answer.code:32:37: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& map[i])) + 1)’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:32:37: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   32 |                 std::cin >> (map[i] + 1);
      |                             ~~~~~~~~^~~~
      |                                     |
      |                                     char*
answer.code:32:37: error: cannot bind rvalue ‘(long long int)(((char*)(& map[i])) + 1)’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:32:37: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   32 |                 std::cin >> (map[i] + 1);
      |                             ~~~~~~~~^~~~
      |                                     |
      |                                     char*
answer.code:32:37: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& map[i])) + 1)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:32:37: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   32 |                 std::cin >> (map[i] + 1);
      |                             ~~~~~~~~^~~~
      |                                     |
      |                                     char*
answer.code:32:37: error: cannot bind rvalue ‘(long int)(((char*)(& map[i])) + 1)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  184 |  ...