답안 #141360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141360 2019-08-07T14:04:04 Z Ruxandra985 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
3 ms 560 KB
#include <cstdio>
#include <vector>
#include <algorithm>
#include "grader.h"

using namespace std;
vector <int> w[600];
vector <int> eul,isl;
int poz;
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;
    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
        isl.clear();
        for (int i=st;i<=mid;i++)
            isl.push_back(eul[i]);
        sol = query(isl);
        if (sol == 0)
            st = mid + 1;
        else dr = mid;
    }
    return eul[st];
}

Compilation message

eastereggs.cpp: In function 'void euler(int, int)':
eastereggs.cpp:13: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:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v.size();i++){
                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 452 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -