This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
int cont, a, n, m, b;
vector<pair<int,int>>junct;
vector<vector<int>>adj;
void dfs(int nodo, vector<bool>&vis){
//cout<< nodo << ' '<< junct[nodo].y<< '\n';
vis[nodo] = true;
if (junct[nodo].x == a) {
//cerr<< junct[nodo].y;
cont++;
}
for (int i = 0; i < (int)adj[nodo].size(); ++i){
if (!vis[adj[nodo][i]]){
//cerr<< "HI\n";
dfs(adj[nodo][i], vis);
}
}
return;
}
int main()
{
cin>> n>> m>> a>> b;
junct.resize(n);
adj.resize(n);
vector<pair<int,int>>w;
for (int i = 0; i < n; ++i){
cin>> junct[i].x >> junct[i].y;
if (junct[i].x == 0)w.push_back({junct[i].y, i});
}
for (int i = 0; i < m; ++i){
int s, d, f;
cin>> s>> d>> f;
s--;d--;
adj[s].push_back(d);
if (f== 2) adj[d].push_back(s);
}
sort(w.begin(), w.end(), greater());
int ans;
for (int i = 0; i < (int) w.size(); ++i){
cont= 0;
vector<bool>vis(n, false);
dfs(w[i].y,vis);
cout<< cont << '\n';
}
return 0;
}
Compilation message (stderr)
tra.cpp: In function 'int main()':
tra.cpp:42:9: warning: unused variable 'ans' [-Wunused-variable]
42 | int ans;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |