QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#308987 | #8136. Rebellious Edge | ucup-team1631# | WA | 58ms | 3716kb | C++20 | 1.6kb | 2024-01-20 14:06:46 | 2024-01-20 14:06:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/scc>
//#include <time.h>
//using namespace atcoder;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
template<class T>
bool chmax(T& p, T q, bool C = 1) {
if (C == 0 && p == q) {
return 1;
}
if (p < q) {
p = q;
return 1;
}
else {
return 0;
}
}
template<class T>
bool chmin(T& p, T q, bool C = 1) {
if (C == 0 && p == q) {
return 1;
}
if (p > q) {
p = q;
return 1;
}
else {
return 0;
}
}
void solve() {
ll N, M;
cin >> N >> M;
vector<vector<pair<ll,ll>>> G(N);
rep(i,M){
ll U,V,W;
cin>>U>>V>>W;
U--;V--;
G[U].push_back({W,V});
}
vb D(N,0);
D[0]=1;
priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> Q;
for(auto v:G[0]){
Q.push(v);
}
ll an=0;
while(!Q.empty()){
auto wn=Q.top();
Q.pop();
ll w=wn.first;
ll n=wn.second;
if(D[n])continue;
an+=w;
D[n]=1;
for(auto k:G[n]){
if(D[k.second])continue;
Q.push(k);
}
}
cout<<an<<endl;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll T;
cin >> T;
rep(t, T)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3500kb
input:
3 5 6 1 2 4 1 3 2 2 3 0 3 4 1 4 5 1 5 2 1 4 4 1 2 4 1 3 6 1 4 8 4 2 1000000 3 3 1 2 100 2 1 10 2 3 1000
output:
5 18 1100
result:
ok 3 number(s): "5 18 1100"
Test #2:
score: -100
Wrong Answer
time: 58ms
memory: 3716kb
input:
50000 4 5 2 4 998973548 2 3 501271695 4 1 778395982 1 4 32454891 1 2 757288934 4 5 1 4 720856669 2 3 665098951 3 4 407461517 2 1 866914401 1 2 457859826 4 5 1 2 75288664 1 4 624893594 3 2 458973866 2 4 769074655 2 3 834773751 4 5 2 3 237060634 2 4 297307882 3 4 200383586 1 2 42856502 3 1 16574713 4 ...
output:
1291015520 1530420294 1534956009 480300722 1366795927 1541095843 2567005573 858095911 1034153425 793861088 605832428 1051598350 612891589 1265994009 517769091 1899616226 1556463491 93634961 960978736 984886788 1696503797 1002892611 1969660290 1431417780 1515267731 977157479 1937478556 654475526 1401...
result:
wrong answer 7th numbers differ - expected: '2493849488', found: '2567005573'