Skip to content

Commit

Permalink
Add 22113.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jun 10, 2024
1 parent 29c894b commit d8cb3d7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 22xxx/22113.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <vector>
using namespace std;

void solve(void) {
int n, m; cin >> n >> m;
vector<int> v(m);
for (int i=0; i<m; i++) cin >> v[i], v[i]--;
vector<vector<int>> a(n, vector<int>(n));
for (int i=0; i<n; i++) for (int j=0; j<n; j++) cin >> a[i][j];

int ans = 0;
for (int i=1; i<m; i++) {
ans += a[v[i-1]][v[i]];
}
cout << ans;
}

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

solve();
return 0;
}

0 comments on commit d8cb3d7

Please sign in to comment.