Submission #129034

# Submission time Handle Problem Language Result Execution time Memory
129034 2019-07-11T13:04:26 Z thanos Min-max tree (BOI18_minmaxtree) C++14
0 / 100
3 ms 1016 KB
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#define pb push_back
using namespace std;
struct edge{
  int x;
  int y;
  int z;
  bool operator<(const edge &rhs)const{return rhs.z<z;};
}q[10005];
struct par{
  int x;
  int y;
  bool operator<(const par &rhs)const{return rhs.x>x;};
};
map<par,int> mym;
vector<int> adj[10005];
bool dfs(int s,int d,int v,bool vis[]){
  vis[s]=true;
  if(s==d){
    return true;
  }
  bool c=false;
  for(int i=0; i<adj[s].size(); i++){
    if(!vis[adj[s].at(i)]){
      if(dfs(adj[s].at(i),d,v,vis)){
        par t; t.x=min(s,adj[s].at(i)); t.y=max(s,adj[s].at(i));
        mym[t]=v;
        c=true;
        break;
      }
    }
  }
  return c;
}
int main(){
  int N;
  cin>>N;
  for(int i=0; i<N-1; i++){
    int t1,t2;
    cin>>t1>>t2;
    adj[t1].pb(t2);
    adj[t2].pb(t1);
    par t; t.x=min(t1,t2); t.y=max(t1,t2);
    mym[t]=-1;
  }
  int K;
  cin>>K;
  for(int i=0; i<K; i++){
    char e;
    cin>>e>>q[i].x>>q[i].y>>q[i].z;
  }
  sort(q,q+K);
  for(int i=0; i<K; i++){
    bool vis[100005]={false};
    dfs(q[i].x,q[i].y,q[i].z,vis);
  }
  for(map<par,int>::iterator it=mym.begin(); it!=mym.end(); it++){
    cout<<(it->first).x<<" "<<(it->first).y<<" "<<it->second<<endl;
  }
  return 0;
}

Compilation message

minmaxtree.cpp: In function 'bool dfs(int, int, int, bool*)':
minmaxtree.cpp:26:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<adj[s].size(); i++){
                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 632 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 632 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -