QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386692#5112. Where Am I?PetroTarnavskyi#Compile Error//C++203.1kb2024-04-11 19:25:302024-04-11 19:25:31

Judging History

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

  • [2024-04-11 19:25:31]
  • 评测
  • [2024-04-11 19:25:30]
  • 提交

answer

#include <bits/stdc++.h> 

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

map<PII, int> mp;

void precalc()
{
	mp[{0, 0}] = 0;
	int x = 0, y = 0;
	int id = 1;
	FOR(i, 0, 400)
	{
		FOR(j, 0, 2 * i + 1)
		{
			y++;
			mp[{x, y}] = id++;
		}
		FOR(j, 0, 2 * i + 1)
		{
			x++;
			mp[{x, y}] = id++;
		}
		FOR(j, 0, 2 * i + 2)
		{
			y--;
			mp[{x, y}] = id++;
		}
		FOR(j, 0, 2 * i + 2)
		{
			x--;
			mp[{x, y}] = id++;
		}
	}
}

int f(const VI& a, const VI& b)
{
	assert(SZ(a) == SZ(b));
	int ptr = 0;
	while (ptr < SZ(a) && a[ptr] == b[ptr])
		ptr++;
	assert(ptr < SZ(a) && a[ptr] < b[ptr]);
	return a[ptr];
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int n, m;
	cin >> m >> n;
	vector<string> s(n);
	for (string& si : s)
		cin >> si;
	reverse(ALL(s));
	precalc();
	FOR(i, -100, 101)
		FOR(j, -100, 101)
			assert(mp.count({i, j}));
	vector<PII> crosses;
	FOR(i, 0, n)
		FOR(j, 0, m)
			if (s[i][j] == 'X')
				crosses.PB({i, j});
	vector<tuple<VI, int, int>> vec;
	vec.reserve(n * m);
	VI cur;
	FOR(i, 0, n)
	{
		FOR(j, 0, m)
		{
			cur.clear();
			for (auto [xcr, ycr] : crosses)
			{
				cur.PB(mp[{xcr - i, ycr - j}]);
			}
			cerr << "sz " << SZ(cur) << endl;
			sort(ALL(cur));
			vec.PB({cur, i, j});
		}
	}
	sort(ALL(vec));
	for (auto [curVec, x, y] : vec)
	{
		cerr << "(" << x << "," << y << ")\n";
		for (int id : curVec)
		{
			cerr << id << " ";
		}
		cerr << endl;
	}
	LL sum = 0, mx = 0;
	vector<PII> vecMx;
	assert(SZ(vec) == n * m);
	FOR(i, 0, SZ(vec))
	{
		const auto& [curVec, x, y] = vec[i];
		int steps = 47 * n * m + 47;
		if (SZ(vec) == 1)
			steps = 0;
		if (i > 0)
			steps = min(steps, f(get<0>(vec[i - 1]), curVec));
		if (i + 1 < SZ(vec))
			steps = min(steps, f(curVec, get<0>(vec[i + 1])));
		sum += steps;
		if (steps > mx)
		{
			mx = steps;
			vecMx.clear();
		}
		if (steps == mx)
		{
			vecMx.PB({y, x});
		}
	}
	sort(ALL(vecMx));
	cout << (db)sum / (n * m) << "\n";
	cout << mx << "\n";
	FOR(i, 0, SZ(vecMx))
	{
		auto [y, x] = vecMx[i];
		if (i)
			cout << " ";
		cout << "(" << x << "," << y << ")";
	}
	cout << "\n";
	return 0;
}
0 2 17 34 58 
(1,3)
0 6 16 32 39 
(1,0)
0 9 13 27 55 
(3,1)
0 21 24 28 46 
(4,4)
0 40 44 71 74 
(0,1)
1 4 11 33 57 
(1,2)
1 7 15 18 31 
(4,3)
1 19 42 45 75 
(3,0)
1 22 25 47 53 
(2,0)
2 7 24 26 54 
(3,3)
2 18 22 41 44 
(0,3)
3 5 35 38 59 
(2,1)
3 6 9 23 29 
(0,0)
3 10 28 32 56 
(3,4)
3 21 39 43 70 
(2,2)
4 8 12 19 22 
(0,4)
4 18 36 60 67 
(1,1)
5 8 10 14 30 
(3,2)
5 11 20 23 45 
(1,4)
5 19 33 37 68 
(4,2)
6 10 43 46 76 
(2,4)
6 14 20 38 69 
(2,3)
7 13 17 21 40 
(4,1)
7 27 44 47 77 
(4,0)
8 45 48 52 78 
4.2000000000
9
(3,1)

詳細信息

answer.code:145:1: error: expected unqualified-id before numeric constant
  145 | 0 2 17 34 58
      | ^