Submission #33821

#TimeUsernameProblemLanguageResultExecution timeMemory
33821mohammad_kilaniSimurgh (IOI17_simurgh)C++14
0 / 100
0 ms2544 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; const int N = 501; int vis[N] , vi = 0 , n; vector< pair<int,int> > g[N], T[N]; vector< int > r , tree , anss; bool ok[N * N]; bool asked[N * N]; int ask(){ return count_common_roads(r); } void DFS(int node){ vis[node] = vi; for(int i=0;i<g[node].size();i++){ if(vis[g[node][i].first] != vi){ tree.push_back(g[node][i].second); T[node].push_back(g[node][i]); T[g[node][i].first].push_back(make_pair(node,g[node][i].second)); DFS(g[node][i].first); } } } bool DFS2(int node,int target){ if(node == target) return true; vis[node] = vi; for(int i=0;i<T[node].size();i++){ int newnode = T[node][i].first; if(vis[newnode] != vi && DFS2(newnode,target)) return true; } return false; } std::vector<int> find_roads(int N, std::vector<int> u, std::vector<int> v) { for(int i=0;i<u.size();i++){ g[u[i]].push_back(make_pair(v[i],i)); g[v[i]].push_back(make_pair(u[i],i)); } vi++; DFS(0); sort(tree.begin(),tree.end()); r = tree; int res = ask(); n = N; for(int i=0;i<n;i++){ bool found = false; for(int j=0;j<g[i].size();j++){ if(asked[g[i][j].second]) continue; //asked[g[i][j].second] = true; int newnode = g[i][j].first; int edge = 0; for(int k=0;k<T[i].size();k++){ vi++; if(DFS2(T[i][k].first,newnode)){ edge = T[i][k].second; break; } } r.clear(); for(int i=0;i<tree.size();i++){ if(tree[i] == edge) continue; r.push_back(tree[i]); } r.push_back(g[i][j].second); sort(r.begin(),r.end()); int cur = ask(); if(cur > res){ ok[g[i][j].second] = true; found = true; } else if(res > cur){ ok[edge] = true; found = true; } } if(!found){ for(int j=0;j<g[i].size();j++){ ok[g[i][j].second] = true; } } } for(int i=0;i<u.size();i++) if(ok[i]) anss.push_back(i); return anss; }

Compilation message (stderr)

simurgh.cpp: In function 'void DFS(int)':
simurgh.cpp:16:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[node].size();i++){
               ^
simurgh.cpp: In function 'bool DFS2(int, int)':
simurgh.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<T[node].size();i++){
               ^
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<u.size();i++){
               ^
simurgh.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<g[i].size();j++){
                ^
simurgh.cpp:54:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k=0;k<T[i].size();k++){
                 ^
simurgh.cpp:62:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0;i<tree.size();i++){
                 ^
simurgh.cpp:79:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<g[i].size();j++){
                 ^
simurgh.cpp:84:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<u.size();i++) if(ok[i]) anss.push_back(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...