QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202305#7343. Bicycle RaceTeam_nameWA 0ms8792kbC++201.2kb2023-10-05 21:49:222023-10-05 21:49:22

Judging History

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

  • [2023-10-05 21:49:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:8792kb
  • [2023-10-05 21:49:22]
  • 提交

answer

#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
#define FOR_EDGE(u, i) for (int i = idx[u]; i; i = next[i])
constexpr int N = 1E5, M = 1E5;
int u[M], v[M]; int a[M];
int deg[N + 1];
int idx[N + 1];
int to[M]; int next[M];
int id[N + 1];
std::vector<std::pair<int, int>> C[N + 1];
int main()
{
	std::ios_base::sync_with_stdio(false), std::cin.tie(nullptr);
	int n, m; std::cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		std::cin >> u[i] >> v[i] >> a[i];
		++deg[u[i]];
		++deg[v[i]];
	}
	std::memset(idx + 1, -1, sizeof(*idx) * n);
	for (int i = 0; i < m; ++i)
	{
		int u = ::u[i], v = ::v[i];
		auto add_edge = [i](int u, int v) {
			to[i] = v, next[i] = idx[u];
			idx[u] = i;
		};
		if (deg[u] < deg[v] || deg[u] == deg[v] && u < v)
			add_edge(u, v);
		else
			add_edge(v, u);
	}
	for (int u = 1; u <= n; ++u)
	{
		FOR_EDGE(u, i)
			id[to[i]] = i;
		FOR_EDGE(u, i)
		{
			int v = to[i];
			FOR_EDGE(v, j)
			{
				int w = to[j];
				if (int k = id[w])
				{
					int s = a[i] + a[j] + a[k];
					C[u].emplace_back(j, s);
					C[v].emplace_back(k, s);
					C[w].emplace_back(i, s);
				}
			}
		}
		FOR_EDGE(u, i)
			id[to[i]] = 0;
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 8792kb

input:

6 9
1 2 3
2 3 1
3 4 2
4 5 1
3 5 7
2 5 2
1 5 3
4 6 2
5 6 1

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements