Submission #875907

#TimeUsernameProblemLanguageResultExecution timeMemory
875907ElenaBMTraffic (CEOI11_tra)C++17
32 / 100
5066 ms36412 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...