QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#691256 | #6341. The Last Battle | L_Hospital_# | Compile Error | / | / | C++17 | 1.5kb | 2024-10-31 10:34:15 | 2024-10-31 10:34:15 |
Judging History
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