# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875451 |
2023-11-19T18:12:25 Z |
lalig777 |
Traffic (CEOI11_tra) |
C++14 |
|
5000 ms |
37324 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
void dfs(int nodo, int &count, vector<bool> &visitado, vector<bool> &east, vector<vector<int> > &listaAdy){
visitado[nodo]=true;
if (east[nodo]==true) count++;
for (int j=0; j<listaAdy[nodo].size(); j++){
int conexion=listaAdy[nodo][j];
if (visitado[conexion]!=true) dfs(conexion, count, visitado, east, listaAdy);
}return;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, A, B;
cin>>n>>m>>A>>B;
vector<pair<int, int> >west;
vector<bool>east(n, false);
int x, y;
for (int i=0; i<n; i++){
cin>>x>>y;
if (x==0) west.push_back(make_pair(y, i));
else if (x==A) east[i]=true;
}sort(west.begin(), west.end());
reverse(west.begin(), west.end());
vector<vector<int> >listaAdy(n);
for (int i=0; i<m; i++){
int a, b, c;
cin>>a>>b>>c;
listaAdy[a-1].push_back(b-1);
if (c==2) listaAdy[b-1].push_back(a-1);
}
for (int i=0; i<west.size(); i++){
int nodo=west[i].second;
vector<bool>visitado(n, false);
int count=0;
dfs(nodo, count, visitado, east, listaAdy);
cout<<count<<'\n';
}
return 0;
}
Compilation message
tra.cpp: In function 'void dfs(int, int&, std::vector<bool>&, std::vector<bool>&, std::vector<std::vector<int> >&)':
tra.cpp:10:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for (int j=0; j<listaAdy[nodo].size(); j++){
| ~^~~~~~~~~~~~~~~~~~~~~~
tra.cpp: In function 'int main()':
tra.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i=0; i<west.size(); i++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
37 ms |
920 KB |
Output is correct |
3 |
Correct |
4 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2136 KB |
Output is correct |
2 |
Execution timed out |
5055 ms |
5460 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
3676 KB |
Output is correct |
2 |
Execution timed out |
5023 ms |
5784 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
7012 KB |
Output is correct |
2 |
Execution timed out |
5066 ms |
12368 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
8928 KB |
Output is correct |
2 |
Execution timed out |
5070 ms |
10328 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
14340 KB |
Output is correct |
2 |
Execution timed out |
5099 ms |
19392 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
22392 KB |
Output is correct |
2 |
Execution timed out |
5073 ms |
30084 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
331 ms |
33968 KB |
Output is correct |
2 |
Execution timed out |
5007 ms |
30976 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
17492 KB |
Output is correct |
2 |
Execution timed out |
5019 ms |
37324 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |