Submission #141354

# Submission time Handle Problem Language Result Execution time Memory
141354 2019-08-07T13:33:49 Z Ruxandra985 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
3 ms 504 KB
#include <cstdio>
#include <vector>
#include "grader.h"

using namespace std;
vector <int> w[600];
vector <int> eul;
void euler (int nod ,int tata){
    int vecin;
    eul.push_back(nod);
    for (int i = 0 ; i < w[nod].size() ; i++){
        vecin = w[nod][i];
        if (vecin!=tata){
            euler (vecin,nod);
            eul.push_back(nod);
        }
    }
}

int findEgg (int n , vector <pair <int,int> > v){
    int st,dr,mid,sol,x,y;
    vector <int> islands;
    for (int i=1;i<=n;i++)
        w[i].clear();
    for (int i=0;i<v.size();i++){
        x = v[i].first;
        y = v[i].second;
        w[x].push_back(y);
        w[y].push_back(x);
    }
    eul.clear();
    euler(1,0); /// eul e un vector cu parc euler , dim 2*n
    st = 0;
    dr = eul.size()-1;
    while (st<dr){
        mid = (st + dr)/2;
        /// iei de la st la mid
        islands.clear();
        for (int i=st;i<=mid;i++)
            islands.push_back(eul[i]);
        sol = query(islands);
        if (sol == 0)
            st = mid + 1;
        else dr = mid;
    }
    return eul[st];
}

Compilation message

eastereggs.cpp: In function 'void euler(int, int)':
eastereggs.cpp:11:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0 ; i < w[nod].size() ; i++){
                      ~~^~~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:25:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v.size();i++){
                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 456 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 504 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 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -