Skip to content

Commit

Permalink
Add 14771.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Aug 29, 2024
1 parent 4a4697b commit 50201ee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 14xxx/14771.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <vector>
using namespace std;

void solve(int idx) {
int n, v; cin >> n >> v;
vector<int> d(n), p(n);
for (int i=0; i<n; i++) cin >> d[i] >> p[i];

int ans = 0;
while (v--) {
int a1, a2, c; cin >> a1 >> a2 >> c; a1--; a2--;
if (d[a1] == 1 || c == 1) ans += p[a1];
if (d[a2] == 1 || c == 2) ans += p[a2];
}
cout << "Data Set " << idx << ":\n" << ans << "\n\n";
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

int k; cin >> k;
for (int i=1; i<=k; i++) solve(i);
return 0;
}

0 comments on commit 50201ee

Please sign in to comment.