답안 #141350

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

using namespace std;
int poz;
void euler (int nod ,int tata, vector <pair <int,int> > v , vector <int> &eul ){
    int x,y;
    eul.push_back(nod);
    for (int i = 0 ; i < v.size() ; i++){
        x = v[i].first;
        y = v[i].second;
        if (x == nod && y!=tata){
            euler (y,nod,v,eul);
            eul.push_back(nod);
        }
        else if (y == nod && x != tata){
            euler (x,nod,v,eul);
            eul.push_back(nod);
        }
    }
}

int findEgg (int n , vector <pair <int,int> > v){
    int st,dr,mid,sol;
    vector <int> eul,islands;
    euler(1,0,v,eul); /// eul e un vector cu parc euler , dim 2*n
    st = 0;
    dr = 2*n-2;
    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, std::vector<std::pair<int, int> >, std::vector<int>&)':
eastereggs.cpp:10:24: 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 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 1424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 4604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -