QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691256#6341. The Last BattleL_Hospital_#Compile Error//C++171.5kb2024-10-31 10:34:152024-10-31 10:34:15

Judging History

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

  • [2024-10-31 10:34:15]
  • 评测
  • [2024-10-31 10:34:15]
  • 提交

Anna

#include<bits/stdc++.h>
# define int long long
# define rep(i, j, k) for (int i = j; i <= k; ++i)
using namespace std;

int n, m, q, s[200005];
int hd[400005], to[400005], nxt[400005], etimer;
int ans, maxx;
void addedge(int u, int v){to[++etimer] = v, nxt[etimer] = hd[u], hd[u] = etimer;}
void dfs(int u, int fa)
{
    for (int i = hd[u]; i; i = nxt[i]) if (to[i] != fa) ans += s[u], dfs(to[i], u);
}

signed main()
{
//	freopen("ex_4.in", "r", stdin);
//	freopen("a.out", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	cin >> n >> m >> q;
	rep(i, 1, n) {cin >> s[i]; if (s[i] > s[maxx]) maxx = s[i];}
	rep(i, 1, m) {int u, v; cin >> u >> v; addedge(u, v), addedge(v, u);}
	dfs(maxx, 0);
	cout << ans << endl;
    return 0;
}

Bruno

#include<bits/stdc++.h>
# define int long long
# define rep(i, j, k) for (int i = j; i <= k; ++i)
using namespace std;

int n, m, q, s[200005];
int hd[400005], to[400005], nxt[400005], etimer;
int ans, maxx;
void addedge(int u, int v){to[++etimer] = v, nxt[etimer] = hd[u], hd[u] = etimer;}
void dfs(int u, int fa)
{
    for (int i = hd[u]; i; i = nxt[i]) if (to[i] != fa) ans += s[u], dfs(to[i], u);
}

signed main()
{
//	freopen("ex_4.in", "r", stdin);
//	freopen("a.out", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	cin >> n >> m >> q;
	rep(i, 1, n) {cin >> s[i]; if (s[i] > s[maxx]) maxx = s[i];}
	rep(i, 1, m) {int u, v; cin >> u >> v; addedge(u, v), addedge(v, u);}
	dfs(maxx, 0);
	cout << ans << endl;
    return 0;
}

详细

/usr/bin/ld: /tmp/ccgpAv0k.o: in function `main':
grader_Anna.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQPpwUo.o:Anna.code:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccgpAv0k.o: in function `main':
grader_Anna.cpp:(.text.startup+0x5c2): undefined reference to `Anna(int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status