# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
673736 | meoww | Traffic (CEOI11_tra) | C++14 | 56 ms | 1236 KiB |
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"
using namespace std;
const int N=7000;
int n,m,a,b,cnt;
bool vis[N];
pair<int,int> jun[N];
vector<int> v[N];
void dfs(int i) {
vis[i]=true;
if (jun[i].first==a) cnt++;
for (int j:v[i]) {
if (!vis[j]) dfs(j);
}
}
signed main() {
cin>>n>>m>>a>>b;
for (int i=1;i<=n;i++) {
cin>>jun[i].first>>jun[i].second;
}
for (int i=0;i<m;i++) {
int c,d,e; cin>>c>>d>>e;
v[c].push_back(d);
if (e==2) v[d].push_back(c);
}
vector<pair<int,int> > wst;
for (int i=1;i<=n;i++) {
if (jun[i].first==0) wst.push_back({jun[i].second,i});
}
sort(wst.rbegin(),wst.rend());
vector<int> ans;
for (int i=0;i<wst.size();i++) {
cnt=0;
for (int j=1;j<=n;j++) vis[j]=false;
dfs(wst[i].second);
ans.push_back(cnt);
}
for (int i:ans) cout<<i<<endl;
}
Compilation message (stderr)
# | 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... |