Submission #472437

#TimeUsernameProblemLanguageResultExecution timeMemory
472437yasseenkamelRailway (BOI17_railway)C++14
0 / 100
1081 ms33360 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> using namespace std; typedef int in; #define int long long #define s second #define f first const long double EPS=1e-9; const int MOD=1e9+7; const int N=1e6; int n,m,k,tar; vector<int> adj[100005]; map<pair<int,int>,int> ed; bool b = 0; int f[100005]; void dfs(int node,int par){ if(b || node == tar){ b = 1; return; } for(int i = 0 ; i < adj[node].size() ; i ++){ int f1 = adj[node][i]; if(f1 == par){ continue; } int idx = ed[{node,f1}]; f[idx] ++; dfs(f1,node); if(b){ return; } f[ed[{node,f1}]] -= (!b); } } in main(){ cin >> n >> m >> k; for(int i = 0 ; i < n - 1 ; i ++){ int x,y; cin >> x >> y; adj[x].push_back(y); adj[y].push_back(x); ed[{x,y}] = i + 1; ed[{y,x}] = i + 1; } for(int i = 0 ; i < m ; i ++){ int x,y; cin >> x; cin >> x >> y; b = 0; tar = y; dfs(x,-1); } vector<int> v; for(int i = 1 ; i <= n ; i ++){ //cout << f[i] << endl; if(f[i] >= k){ v.push_back(i); } } cout << v.size() << endl; for(int i = 0 ; i < v.size() ; i ++){ cout << v[i] << " "; } return 0; }

Compilation message (stderr)

railway.cpp: In function 'void dfs(long long int, long long int)':
railway.cpp:27:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0 ; i < adj[node].size() ; i ++){
      |                     ~~^~~~~~~~~~~~~~~~~~
railway.cpp: In function 'in main()':
railway.cpp:68:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |  for(int i = 0 ; i < v.size() ; i ++){
      |                  ~~^~~~~~~~~~
#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...