QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#440668#7259. RobotsI_Love_Sonechka#Compile Error//C++173.1kb2024-06-13 22:30:282024-06-13 22:30:29

Judging History

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

  • [2024-06-13 22:30:29]
  • 评测
  • [2024-06-13 22:30:28]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// c++ short types
#define vt vector
//typedef long long ll;
typedef long double ld;

void whattime() { cout << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; }
const int64_t inf = 1e18;
const int mod = 998244353;
bool debug = false;
const ld eps = 1e-9;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

string dir = "URDL";
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void solve() {
	int n;
	int64_t T;
	cin >> n >> T;
	vt<int> x(n), y(n);
	vt<char> c(n);
	map<pair<int, int>, int> ids;
	map<int, vt<pair<int, int>>> x_line;
	map<int, vt<pair<int, int>>> y_line;
	for(int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i] >> c[i];
		ids[make_pair(x[i], y[i])] = i;
		x_line[x[i]].push_back(make_pair(y[i], i));
		y_line[y[i]].push_back(make_pair(x[i], i));
	}
	vt<vt<int>> g(n);
	for(auto &zz: x_line) {
		auto &v = zz.second;
		sort(v.begin(), v.end());
		for(int i = 0; i + 1 < int(v.size()); ++i) {
			g[v[i].second].push_back(v[i+1].second);
			g[v[i+1].second].push_back(v[i].second);
		}
	}
	for(auto &zz: y_line) {
		auto &v = zz.second;
		sort(v.begin(), v.end());
		for(int i = 0; i + 1 < int(v.size()); ++i) {
			g[v[i].second].push_back(v[i+1].second);
			g[v[i+1].second].push_back(v[i].second);
		}
	}
	auto get_id = [&](char c) {
		for(int i = 0; i < 4; ++i) if(dir[i] == c) {
			return i;
		}
		assert(false);
		return -1;
	};
	auto is_ok = [&](int x, int y, int nx, int ny, int type) {
		int dxx = nx - x, dyy = ny - y;
		if(dxx + dyy == 0) {
			return true;
		}
//		string dir = "URDL";
		int ztype = 0;
		if(dyy > 0) {
			ztype = 0;
		} else if(dxx > 0) {
			ztype = 1;
		} else if(dyy < 0) {
			ztype = 2;
		} else if(dxx < 0) {
			ztype = 3;
		}
		return ztype == type;
	};
	vt<vt<int64_t>> dp(n, vt<int64_t>(4, inf));
	dp[0][get_id(c[0])] = 0;
	set<pair<int64_t, pair<int, int>>> st;
	st.insert(make_pair(0ll, make_pair(0, get_id(c[0]))));
	while(not st.empty()) {
		auto u = st.begin()->second;
		int e = u.first, type = u.second;
		st.erase(st.begin());
		for(auto to: g[e]) if(is_ok(x[e], y[e], x[to], y[to], type)) {
			int delta = abs(x[e]-x[to]) + abs(y[e]-y[to]);
			if(delta + dp[e][type] < dp[to][type]) {
				st.erase(make_pair(dp[to][type], make_pair(to, type)));
				st.insert(make_pair(dp[to][type] = delta + dp[e][type], make_pair(to, type)));
			}
		}
		int cur_id = get_id(c[e]);
		if(dp[e][cur_id] > dp[e][type]) {
			st.erase(make_pair(dp[e][cur_id], make_pair(e, cur_id)));
			st.insert(make_pair(dp[e][cur_id] = dp[e][type], make_pair(e, cur_id)));
		}
	}
	for(int i = 0; i < n; ++i) {
		int64_t time = *min_element(dp[i].begin(), dp[i].end());
		int64_t resx = x[i], resy = y[i];
		int type = get_id(c[i]);
		int64_t dtime = max(0ll, T - time);
		resx += dtime * dx[type];
		resy += dtime * dy[type];
		cout << resx << ' ' << resy << '\n';
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int tt = 1;
	if(debug) {
		tt = 1e5;
	} else {
//		cin >> tt;
	}
	for(int t = 0; t < tt; ++t) {
		solve();
	}
	return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:104:36: error: no matching function for call to ‘max(long long int, int64_t)’
  104 |                 int64_t dtime = max(0ll, T - time);
      |                                 ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:104:36: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int64_t’ {aka ‘long int’})
  104 |                 int64_t dtime = max(0ll, T - time);
      |                                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:104:36: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int64_t’ {aka ‘long int’})
  104 |                 int64_t dtime = max(0ll, T - time);
      |                                 ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:104:36: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
  104 |                 int64_t dtime = max(0ll, T - time);
      |                                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:104:36: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
  104 |                 int64_t dtime = max(0ll, T - time);
      |                                 ~~~^~~~~~~~~~~~~~~