답안 #141352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141352 2019-08-07T13:31:02 Z Ruxandra985 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
3 ms 552 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=0;i<v.size();i++){
        x = v[i].first;
        y = v[i].second;
        w[x].push_back(y);
        w[y].push_back(x);
    }
    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:23:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v.size();i++){
                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 424 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 504 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 552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -